arithmetic

You can use Python like a calculator:

print(2 + 2 - 1)
print(7 * 3)
print(15 / 2)
3
21
7.5

You can do exponentiation with the ** operator:

python(2 ** 3)
8

You can store these calculations in variables:

how_many_times = 70 * 7
print(how_many_times)
490

You can use variables with arithmetic operators too:

foo = 7
bar = foo + 4
baz = foo * bar
print(baz)
77

previous: exercises next: expressions