SyntaxStudy
Sign Up
Python Beginner 8 min read

Python Operators

Python Operators

Python supports arithmetic, comparison, logical, and assignment operators.

Arithmetic

print(10 + 3)   # 13
print(10 - 3)   # 7
print(10 * 3)   # 30
print(10 / 3)   # 3.333...
print(10 // 3)  # 3 (floor division)
print(10 % 3)   # 1 (modulo)
print(2 ** 8)   # 256 (exponent)

Comparison

print(5 == 5)   # True
print(5 != 4)   # True
print(5 > 3)    # True

Logical

print(True and False)  # False
print(True or False)   # True
print(not True)        # False
Pro Tip

Python uses ** for exponentiation, not ^.