Himanshu SharmaSoftware engineer
Let’s talk

Beginner to intermediate · 70 lessons

Python Tutorial for beginners

A free written Python tutorial for complete beginners. Short lessons cover variables, strings, control flow, collections, functions, files, errors, classes, generators and decorators, with the real output of every example, and end with two small projects.

Syllabus

Getting started

  1. What Python is and what it is used for8 min
  2. Installing Python8 min
  3. Your first Python program10 min
  4. Running code: the REPL and scripts10 min
  5. Variables and names12 min
  6. Comments and code style9 min
  7. Input and output12 min

Data types and operators

  1. Numbers: int and float12 min
  2. Arithmetic operators12 min
  3. Strings13 min
  4. Type conversion12 min
  5. Booleans and comparisons11 min
  6. and, or and not12 min
  7. None and truthiness11 min

Control flow

  1. if, elif and else13 min
  2. while loops12 min
  3. for loops and range()13 min
  4. break, continue and loop else11 min
  5. Nested loops12 min
  6. Control flow practice15 min

Working with text

  1. String methods14 min
  2. Indexing and slicing strings13 min
  3. f-strings and formatting13 min
  4. Text processing practice15 min

Collections

  1. Lists14 min
  2. List methods14 min
  3. Tuples12 min
  4. Sets13 min
  5. Dictionaries14 min
  6. Dictionary methods and loops14 min
  7. Nested collections15 min
  8. Comprehensions14 min
  9. Sorting14 min

Functions

  1. Functions12 min
  2. Parameters and return values13 min
  3. Default and keyword arguments12 min
  4. *args and **kwargs12 min
  5. Scope: local, global and nonlocal13 min
  6. Lambda functions11 min
  7. Recursion13 min
  8. map, filter and zip12 min

Errors and files

  1. Errors and exceptions12 min
  2. try, except, else and finally13 min
  3. Raising and defining exceptions13 min
  4. Reading files13 min
  5. Writing files12 min
  6. CSV and JSON14 min
  7. Paths with pathlib13 min

Modules and packages

  1. Modules and import14 min
  2. A tour of the standard library14 min
  3. pip and virtual environments12 min
  4. Packages and project layout14 min

Object-oriented programming

  1. Classes and objects12 min
  2. __init__ and self12 min
  3. Instance and class attributes12 min
  4. Instance, class and static methods13 min
  5. Inheritance14 min
  6. Polymorphism and duck typing12 min
  7. Encapsulation and properties13 min
  8. Special (dunder) methods14 min
  9. Dataclasses12 min

Going further

  1. Iterators and generators14 min
  2. Decorators14 min
  3. Context managers and with13 min
  4. Regular expressions15 min
  5. Dates and times14 min
  6. Type hints12 min

Practice

  1. Testing with unittest15 min
  2. Project: a number guessing game25 min
  3. Project: a contact book30 min