EasyEnv
Python
Beginner

Python

Learn Python end to end. Syntax, data structures, OOP, generators, async, testing, and packaging.

19 lessons9.3h hands-on11 languages
Start learning freePython course

19 lessons, in order

  1. 1

    Hello, Python

    Welcome. If you have never written code before, you are in the right place. Python is a programming language, which is a way to give a computer...

    VariablesPrintRepl
    20 min
  2. 2

    Numbers and Strings

    Welcome back. In lesson 01 you ran your first Python file and learned that a variable is a labelled box that holds a value. Today we look at the two...

    IntegersFloatsString concatenationF-strings
    25 min
  3. 3

    Asking the User a Question

    So far you have written programs that always do the same thing when you click play. Run them ten times, get the same ten answers. They are useful,...

    Input()String return typeInt() and float() conversionInteractive programs
    15 min
  4. 4

    Control Flow

    Up to now your programs have run straight through, top to bottom, one line after the other. That is fine for greetings, but most useful programs need...

    If/elif/elseComparison operatorsBoolean operatorsWhile loopsFor loopsBreak and continue
    30 min
  5. 5

    Lists and Tuples

    So far each variable has held a single value: one number, one string. Real programs usually need to keep a small group of related values together,...

    List creationIndexingSlicingAppendPopIteration+2
    30 min
  6. 6

    Dictionaries and Sets

    Welcome back. Lists are great when order matters and you reach for items by position, but a lot of real data is organized by name: a person has an...

    Dict basicsGet with defaultIterate keysIterate valuesIterate itemsSets+1
    30 min
  7. 7

    Functions

    Welcome back. So far you have used a few functions that came with Python, like print() and len(). In this lesson you are going to write your own. A...

    DefParametersDefault valuesKeyword arguments*args and **kwargsReturn values+1
    30 min
  8. 8

    Comprehensions

    You already know how to write a for loop that builds a new list, dict, or set one item at a time. A comprehension is a shorter way to write that same...

    List comprehensionsDict comprehensionsSet comprehensionsConditional expressionsGenerator expressionsReadability tradeoffs
    25 min
  9. 9

    Files and IO

    A program that only prints to the terminal forgets everything the moment it finishes. The next step, and the one that makes Python suddenly feel...

    Open with withReading linesWriting filesPathlib.PathJson readJson write
    30 min
  10. 10

    Modules and Packages

    Up to now every program has lived in a single file. That is fine while you are learning, but real projects spread their code across many files so...

    ImportFrom importWriting your own moduleIf __name__ == "__main__"Packages__init__.py
    30 min
  11. 11

    Classes and OOP

    Welcome to one of the bigger ideas in Python. So far you have used built-in tools (strings, lists, dicts, functions) to shape data. In this lesson...

    Class definition__init__Instance attributesClass attributesMethods__repr__
    35 min
  12. 12

    Inheritance and Composition

    In lesson 11 you built classes from scratch. In real code, classes rarely live alone. Sometimes one class is a more specific version of another (a...

    SubclassingSuper()Method overridingCompositionWhen to choose composition
    30 min
  13. 13

    Exception Handling

    You have already met errors. Every time you mistyped a name, divided by zero, or asked a list for an index that did not exist, Python stopped and...

    TryExceptElseFinallyRaiseCustom exception classes+1
    30 min
  14. 14

    Iterators and Generators

    You already know how to write for item in something: from earlier lessons. In this lesson we look under the hood and find out what Python is actually...

    Iterator protocolYieldGenerator functionsGenerator expressionsLazy evaluation
    30 min
  15. 15

    Decorators

    Welcome to one of Python's trickier topics. A decorator is a small wrapper you put around a function so it gains a little extra behaviour (logging,...

    Functions are objectsWrapper functions@decorator syntaxFunctools.wrapsParametrized decorators
    30 min
  16. 16

    Context Managers

    Welcome back. Ever since lesson 09 you have been writing with open(...) as f: and trusting that the file gets closed when the block ends. This lesson...

    With statement__enter__ and __exit__Writing your own context managerContextlib.contextmanager
    25 min
  17. 17

    Concurrency: Threads and Async

    Welcome back. So far our programs have done one thing at a time, top to bottom, and that has worked fine. The trouble starts when a program spends...

    GIL in plain languageConcurrent.futures.ThreadPoolExecutorAsyncio basicsAsync defAwaitWhen to use threads vs async
    40 min
  18. 18

    Testing with pytest

    Welcome back. Up to now you have run code and checked the output with your eyes. That works for a few lines, but the moment you change anything, you...

    Test functionsAssertRunning pytestParametrizeFixtures
    35 min
  19. 19

    Packaging and Deployment

    So far you have written Python that you (and only you) run by typing python something.py. This lesson is about the small, mostly-mechanical step that...

    Pyproject.tomlPip install -eConsole scriptsBuilding a wheelPublishing to PyPI
    35 min
Python Course: Hands-on, in 11 Languages | Engineering Courses