There are two main number types we will work with in this session
- Integers which are whole numbers.
- Floating Point numbers which are numbers with a decimal.
Let’s explore with basic math with Python
We will also discuss how to create variables and assign them values.
Using complier pleae test the following arithmetic operators hands-on excercise for you
2+1
3
2-1
1
2*2
4
3/2
1.5
Modulo or Mod operator
7 / 4
1.75
7 % 4
3
50 % 5
0
23 % 2
1
20 % 2
0
2 ** 3 // to the power of 3
8
practicle
2 + 10 * 10 + 3
105
(2 + 10) * (10 + 3)
156
X = 10 + 3 * 2
print(x)
Order of operator precedence
exponentiation 2**3
multiplication or division
addition or subtraction
exponentiation 10 + 3 * 2 ** 2
ans is 22
2**2 =4
3*4 = 12
10+12 =22
Parenthesis using always given priority
X = (2 + 3) * 10 – 3
Print(x)
(2+3) = 5
5 * 10 = 50 -3
Output:
47