Your first instruction
print("Python is running in your browser!")
Write Python. Understand every error.
Python basics · topic 1 of 25
Python is a programming language: a precise way of giving instructions to a computer. It was created by Guido van Rossum and first released in 1991. It is popular because its code reads almost like English, and it is used for data science, artificial intelligence, websites, automation and teaching.
A Python program is a list of instructions called statements. Python runs them one at a time, from the top line to the bottom line.
print("Good morning") print("Time for Python")
Lines that start with # are comments. Python skips them completely. Comments are notes for people who read your code.
Python can also work as a calculator. It follows the usual order of operations, so multiplication happens before addition unless you use brackets.
print() shows a value on the screen.# is a comment and is ignored.print works, Print does not.print() shows a value on the screen, and text after # is a comment that Python ignores.print works but Print does not.Print("hi") with a capital P. Python does not recognise the name. Read the NameError guide.
print("Python is running in your browser!")
print("Step 1: wake up") print("Step 2: brush teeth") print("Step 3: go to class")
# This whole line is a comment, so Python ignores it print("Only this line is shown") # a comment can also sit after code # print("This line will not run")
print(12 + 30) print(7 * 8) print(100 - 58) print(2 + 3 * 4) print((2 + 3) * 4)
5 quick questions to check your understanding. Choose an answer for each, then press Check answers.
print(2 + 3 * 4)
Multiplication happens before addition, so 3 * 4 = 12 is added to 2.
A line starting with # is a comment. In the first option, # is inside a string, so it is just text.
print((2 + 3) * 4)
Brackets are worked out first: 2 + 3 = 5, then 5 * 4 = 20.
Python runs statements one at a time, from top to bottom.
Print("hi") with a capital P?Python is case-sensitive. Print is a different, unknown name, so you get a NameError.