Skip to content
wannacode

The language you are learning

Problem

Why Python

There are hundreds of programming languages. Each one is good for something, but not equally good for everything. Before you spend months on one of them, it is fair to know where you will use it.

Python is a language in which programs are short to write and read almost like plain text:

  • data and artificial intelligence: analyzing tables, drawing charts, training models. Most machine learning libraries are used from Python;
  • automation: small programs that rename thousands of files, fill in spreadsheets or check a website every morning;
  • websites and web services: the server side, with libraries such as Django and FastAPI;
  • science and education: in many universities the first language is Python, and scientists use it for calculations and experiments.

Python dates from 1991. A new version comes out every year, and the ready-made libraries number in the hundreds of thousands.

The idea

From text to program

The program you write is plain text in a file. Here is a whole program:

shop.py
print("Order #1024 has been accepted.")
Output
Order #1024 has been accepted.

Yes, that is the whole program: one line. We will get to the words in it in the lesson "Your first program". What matters here is something else: the computer's processor does not understand this text. Something has to translate it.

  1. You write the source code in a file named shop.py.
  2. You run it with the command python shop.py. The python program is called an interpreter. It first checks how the whole file is written and translates it into bytecode. This happens in memory, every time you run the program: there is no separate compile step for you to run.
  3. The same interpreter runs the bytecode, line by line.

There is a Python for Windows, macOS and Linux. That is why you can take shop.py itself to another computer and it runs without any change. This is called platform independence.

print("Order #1024 has been accepted.")
Step by step, in words
  1. You write the source code: plain text in the file shop.py.
  2. There is no separate compiler for you to run: Python will read the file itself.
  3. So what goes to another computer is shop.py itself, not a compiled file.
  4. The same shop.py goes unchanged to Windows, macOS and Linux.
  5. Python on each system checks the file, translates it into bytecode and runs it. The output is the same.
More precisely, if you are curious
  • The check covers the whole file. If a parenthesis is missing on the second line, the program prints nothing, not even the first line: Python stops with a SyntaxError and the line number before it runs anything at all. A misspelled name (totl instead of total) is different. That error (NameError) shows up only when the program reaches its line, and the lines above it have already run.
  • Standard Python (CPython) does not translate the program into machine code. The interpreter runs the bytecode, so for heavy calculations Python is slower than Java and C#. The libraries for calculations (NumPy) are written in C and do the heavy part fast. Since Python 3.13 there is also JIT compilation (translation into machine code while the program runs), but it is experimental and turned off by default.
  • The bytecode of the file you run stays in memory. Python writes bytecode to disk (the __pycache__ folder, .pyc files) only for the files the program brings in with import, so it does not have to translate them every time.
  • Memory. Every program takes up memory for its data. In languages like C, the programmer frees the memory that is no longer needed, and if they forget or get it wrong, the program starts taking more and more memory or crashes. Python does this for you: the garbage collector finds the data the program can no longer reach and frees its memory.
  • In Python, the memory of most data is freed as soon as nothing in the program points to it, and the garbage collector catches the more complex cases.

The idea

What you will learn

The course is made of modules. Each module uses only things from the ones before it:

  1. Language basics: variables, input and output, calculations, conditions, loops, lists, text.
  2. Functions: code you write once and call many times.
  3. Classes and objects: your own types, such as Order or Student.
  4. Inheritance and polymorphism: what several types share, in one place.
  5. Errors and exceptions: what the program does when something goes wrong.
  6. Text and files: working with strings, search patterns (regex) and files.
  7. Collections: lists, stack, queue, dictionaries, sets.
  8. Modern Python: lambda functions, processing data in steps and the newer features of the language.
  9. Real-world programs: tests, concurrency, networking, databases.

Off the main path there are games and projects: whole programs you build step by step.

The libraries Python is best known for (NumPy and pandas for data, PyTorch for artificial intelligence) are not in this course. It teaches the language itself. After it you will have everything you need to learn them on your own.

The idea

How you learn here

Each lesson is a series of cards, one idea per card. It usually starts with a real-world problem, then shows what is really going on, often with an animation next to the code. After that comes a small task: predict the output, fill in what is missing, find the bug. At the end there is an exercise you solve in your own editor, and a short quiz.

Your progress is saved in the browser: the lesson picks up from the card you reached.

The map of the whole course is on the course home page.

Do not skip the exercises. Reading code and writing code are different skills, and the second one comes only from writing.

The idea

Errors are part of the job

Your first programs will often not start. You will forget a quote, a parenthesis or a colon, or indent a line the wrong way, and Python will refuse to run the file.

This is not a grade on you. The error message is there to help: it tells you which line the problem is on and what it is. Experienced programmers see these messages every day too. The difference is that they have learned to read them calmly. We will start reading them in the very first lesson with code.

If something will not work for a long time, leave it and come back a bit later. Often you spot the error right away when you look at it again.

In short

In short

  • Python is used for data and artificial intelligence, automation, servers and science.
  • You run the source code (shop.py) with python shop.py: the interpreter checks the file, translates it into bytecode and runs it. The same file runs on any system.
  • Memory is freed automatically by the garbage collector.
  • The course is made of modules, and each lesson of cards. The exercises are in your own editor.
  • An error message is help, not a grade.

Next comes getting your computer ready: what to install so you can run your first program.

Made by Ivo Gergov as part of Evo Tech's campaign for accessible programming education ·