The Basic Types
Python has four basic types you'll use constantly: int (whole numbers), float (decimals), str (text), and bool (True/False).
age = 20 # int
gpa = 4.5 # float
name = "Ada" # str
passed = True # bool
Check any value's type with type():
print(type(age))
Arithmetic operators
print(7 + 3) # 10
print(7 - 3) # 4
print(7 * 3) # 21
print(7 / 3) # 2.333... -- / always gives a float
print(7 // 3) # 2 -- // is floor (integer) division
print(7 % 3) # 1 -- % is the remainder
print(7 ** 2) # 49 -- ** is exponentiation
Comparison and logical operators
print(5 == 5) # True
print(5 != 3) # True
print(5 > 3 and 2 < 4) # True
print(5 > 3 or 2 > 4) # True
print(not True) # False
Why This Matters for Your Exams
/ vs // is the single most common source of "off by a fraction" bugs -- / always produces a float in Python 3, even when both operands are whole numbers, unlike some other languages.
Try it yourself
lock
Real-time practice is a paid add-on
Reading units and the practice quiz are free. Pay once to unlock running real code for PYTHON.

