What a program is
A program is a list of instructions the computer follows from top to bottom. Python is a popular language for writing them because it reads almost like English.
Showing text
print() shows whatever you put in the brackets:
print("Hello, world")
Text in quotes is called a string. You can join strings with +:
print("Good " + "morning") # shows: Good morning
Anything after # is a comment: a note for people, which Python ignores.
Variables
A variable is a name that holds a value. The = sign stores the value on the right under the name on the left:
name = "Amina"
age = 21
print(name) # shows: Amina
You can change a variable by storing something new in it, even using its old value:
age = age + 1
print(age) # shows: 22
Good names
A variable name may use letters, digits and _, but it can't start with a digit, can't contain spaces, and can't be one of Python's own words such as if or class. total_price is fine; 2price and total price are not.
Asking the user
input() waits for the user to type something and gives it back as a string:
city = input("Where do you live? ")
print("Hello from " + city)
Guided practice
What does this show?
score = 10
score = score + 5
print(score)
The first line stores 10. The second takes the old value, adds 5 and stores 15. So it shows 15.