Tsallaka zuwa abun ciki
Justice Tech School

Numbers

Python has int (any size), float and complex numbers. Operators are + - * / (always a float), // (floor division), % (remainder) and ** (power). Use round() to round and abs() for the absolute value.

Example
print(7 + 3, 7 - 3, 7 * 3)
print(7 / 2)
print(7 // 2)
print(7 % 2)
print(2 ** 10)
print(round(3.14159, 2))
print(abs(-5))
print(0.1 + 0.2)

Result

10 4 21
3.5
3
1
1024
3.14
5
0.30000000000000004

Exercise

Divide and drop the decimal part.

print(7  2)

Quiz Test

What is 7 // 2?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.