beginnerBasics
Operators
Arithmetic, comparison, logical, assignment, and other operators.
01Arithmetic Operators
Used for basic mathematical operations.
Python
1a, b = 15, 423print(a + b) # 19 Addition4print(a - b) # 11 Subtraction5print(a * b) # 60 Multiplication6print(a / b) # 3.75 Division7print(a // b) # 3 Floor division8print(a % b) # 3 Modulus9print(a ** b) # 50625 Exponentiation
Output
19 11 60 3.75 3 3 50625
02Comparison Operators
Return True or False by comparing two values.
Python
1x, y = 10, 2023print(x == y) # False4print(x != y) # True5print(x > y) # False6print(x < y) # True7print(x >= y) # False8print(x <= y) # True
Output
False True False True False True
03Logical Operators
Combine conditional statements using and, or, not.
Python
1a, b = True, False23print(a and b) # False4print(a or b) # True5print(not a) # False
Output
False True False