Meet Python
Why Python reads almost like English, and how to use it as a super calculator.
Code runs right here in your browser. Nothing to install.
Learn it
The Python interpreter reads your code one line at a time and runs it.
Deep down, computers only understand machine code: long patterns of 1s and 0s. Writing that by hand is painful, so people invented high-level languages like Python that look more like English. A program called the Python interpreter reads your code one line at a time, from top to bottom, and carries out each instruction.
Python was created by Guido van Rossum and released in 1991. It is popular because it is easy to read and has ready-made tools for almost everything: games, websites, robots, data science and artificial intelligence.
Python is also a brilliant calculator. print(2 + 3) prints 5 because Python works out the sum first. But print("2 + 3") prints the text 2 + 3, because anything inside quote marks is treated as text, not maths.
print(2 + 3) print("2 + 3") print(60 * 60) print("Hours in a week:", 24 * 7)
Try it yourself
+10 XPMake Python work out how many hours are in a year (365 days, 24 hours each). Print the answer using a calculation, not by typing the number.
Create a free account to start this lab
Sign in to write, run and check your code here. Your progress, XP and code are saved to your account. No card needed.
Capture the flag
+10 XPWhat does print("5 + 5") show in the terminal?
Create a free account to start this lab
Sign in to answer the flag question. Your progress, XP and code are saved to your account. No card needed.
Time calculator
+20 XPPrint two results using calculations: the number of seconds in a day and the number of minutes in a week. Add a label to each line, like Seconds in a day: 86400.
Create a free account to start this lab
Sign in to do this homework and have it checked. Your progress, XP and code are saved to your account. No card needed.