Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

PY
Python
0/14 completed
Beginner
Hello PythonVariables and typesWorking with stringsConditions and loopsFunctions
Intermediate
Lists, tuples, dicts and setsFiles and exceptionsModules and the standard library
Advanced
Classes and OOPIterators and generatorsDecorators and context managers
Pro
Async PythonTesting and type hintsVirtual environments, packages and real projects
Tracks / Python / Beginner

Hello Python

Python is one of the most popular programming languages in the world, and one of the easiest to learn. Its code reads almost like English, so you can focus on solving problems instead of fighting syntax.

What is Python used for?

Area Examples
Automation and scripting Rename 1,000 files, fill in spreadsheets, scrape websites
Data analysis pandas, Jupyter notebooks, charts with matplotlib
AI and machine learning PyTorch, TensorFlow, scikit-learn, LLM apps
Web backends Django, FastAPI, Flask
DevOps and tools Ansible, cloud SDKs, command-line tools
Education and science Taught in universities worldwide; used by NASA and CERN

Python was created by Guido van Rossum and first released in 1991. Today's Python is Python 3. (Python 2 reached end of life in 2020, so ignore old tutorials that use print "hi" without brackets.)

Your first program

The editors in this track run real Python 3.14 in your browser. Press ▶ Run:

Python · editable

print() is a function that displays whatever you put inside the brackets. Text goes inside quotes (single '…' or double "…", both work).

Python runs your code from top to bottom, one line at a time:

Python · editable

print accepts several values separated by commas, and puts a space between them. Everything after # is a comment: notes for humans that Python ignores.

Python as a calculator

Python · editable

Indentation matters

Most languages use { } to group code. Python uses indentation (4 spaces by convention), which is why Python code always looks tidy:

Python · editable

Wrong indentation is an error. Python tells you exactly where:

Python · editable

Read that error from the bottom up: the last line says what went wrong, the lines above say where.

Getting input

input() asks the user to type something. In these editors, you type the input in the Input box below the code (one line per input() call). Try changing the values and running again:

Python · editable

The f before the quotes makes an f-string: anything in { } is replaced by its value. You'll use f-strings constantly.

Installing Python on your computer

  1. Download Python 3 from python.org (Windows and macOS), or use your package manager: brew install python, sudo apt install python3. On Windows, tick "Add python.exe to PATH" in the installer.
  2. Check it works in a terminal:
bash
python3 --version        # Windows: python --version
  1. Write code in an editor such as VS Code (with the Python extension) or PyCharm, save it as hello.py, and run it:
bash
python3 hello.py
  1. Or type python3 alone to open the REPL, an interactive prompt where each line runs as you press Enter. Great for quick experiments. Type exit() to leave.

💡 You can also experiment any time in the Python online compiler.

Practice

Write a program that:

  1. Asks for the user's name and favourite number (use the Input box).
  2. Prints a greeting with their name.
  3. Prints their favourite number doubled and squared.
Python · editable
✎ Check your understanding

1.What does print(10 / 4) show in Python 3?

2.How does Python know which lines belong inside an if?

3.What type of value does input() return?