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:
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:
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
Indentation matters
Most languages use { } to group code. Python uses indentation (4 spaces by convention), which is why Python code always looks tidy:
Wrong indentation is an error. Python tells you exactly where:
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:
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
- 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. - Check it works in a terminal:
python3 --version # Windows: python --version- Write code in an editor such as VS Code (with the Python extension) or PyCharm, save it as
hello.py, and run it:
python3 hello.py- Or type
python3alone to open the REPL, an interactive prompt where each line runs as you press Enter. Great for quick experiments. Typeexit()to leave.
💡 You can also experiment any time in the Python online compiler.
Practice
Write a program that:
- Asks for the user's name and favourite number (use the Input box).
- Prints a greeting with their name.
- Prints their favourite number doubled and squared.
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?