Python works with two main types of numbers:
5
, 42
, 1000
3.14
, 2.0
, 99.99
You can assign numbers to variables just like strings:
age = 25
price = 19.99
Python can do standard arithmetic:
5 + 3
→ 8
10 - 4
→ 6
6 * 7
→ 42
20 / 5
→ 4.0
(note: division always returns a float)2 ** 3
→ 8
You can also combine variables in operations:
total = price * 3
print(total)
Would display 59.97