Python Guide #5: Numbers
In this tutorial, I will show you how you can perform math operations in Python on numbers.
Addition
a = 5
b = 10
c = a + b
print(c)
Output:
15
a = 5
a += 10
print(a)
Output:
15
Subtraction
a = 10
b = 5
c = a - b
print(c)
Output:
5
a = 10
a -= 5
print(a)
Output:
5
Multiplication
a = 10
b = 5
c = a * b
print(c)
Output:
50
a = 10
a *= 5
print(a)
Output:
50
Division
a = 10
b = 2
c = a / b
print(c)
Output:
5
Exponent
a = 2 ** 3
# That means 2 to the power of 3
print(a)
Output
8