Python - 4
Python - 4: Numbers & Math
Python can work with numbers and perform basic math operations.
Your challenge: Try addition, subtraction, multiplication, and division, then store a number in a variable and print it.
Basic math operators
Python uses familiar symbols for math: + for addition, - for subtraction, * for multiplication, and / for division.
For example: print(4 * 6) prints the result of the calculation.
Store numbers in variables
Numbers do not need quotation marks: score = 100
You can then use the variable in calculations: print(score + 25)
Try it: Change the numbers and create one calculation using two number variables.
Good Python habit: Use parentheses when you want to make the order of a calculation extra clear.
👀 Show Example Solution
print(15 + 5) print(30 - 10) print(7 * 3) print(40 / 8) age = 25 print(age) first_number = 8 second_number = 12 print(first_number + second_number)
Python calculates each expression first, then print() displays the result.
