a, b = 17, 5
print(a + b) # 22 Addition
print(a - b) # 12 Subtraction
print(a * b) # 85 Multiplication
print(a / b) # 3.4 Division (ALWAYS float)
print(a // b) # 3 Floor division
print(a % b) # 2 Modulus (remainder)
print(a ** b) # 1419857 Exponentiation
# Division always returns float!
print(10 / 2) # 5.0 (not 5)
print(10 // 2) # 5 (use // for int division)
# Negative floor division (tricky!)
print(-7 // 2) # -4 (floors toward negative infinity)
print(-7 % 3) # 2 (result has sign of divisor)x, y = 10, 20
print(x == y) # False Equal
print(x != y) # True Not equal
print(x < y) # True Less than
print(x > y) # False Greater than
print(x <= y) # True Less or equal
print(x >= y) # False Greater or equal
# Chained comparisons (Pythonic!)
age = 25
print(18 <= age <= 65) # True
print(0 < x < 100 < y) # True
# Equivalent to: (0 < x) and (x < 100) and (100 < y)a, b = True, False
print(a and b) # False (both must be True)
print(a or b) # True (at least one True)
print(not a) # False (negation)
# Short-circuit evaluation
print(0 and print('never')) # 0 (print never runs!)
print(1 or print('never')) # 1 (print never runs!)
print(0 or print('runs')) # prints 'runs' then None
# Returns the VALUE, not just True/False
print(1 and 2) # 2
print(0 and 2) # 0
print(0 or 'hello') # 'hello'
print('' or 'default') # 'default'x = 10
x += 5 # x = x + 5 → 15
x -= 3 # x = x - 3 → 12
x *= 2 # x = x * 2 → 24
x /= 4 # x = x / 4 → 6.0
x //= 2 # x = x // 2 → 3.0
x **= 3 # x = x ** 3 → 27.0
x %= 5 # x = x % 5 → 2.0a, b = 12, 10 # 1100, 1010
print(a & b) # 8 (1000) AND
print(a | b) # 14 (1110) OR
print(a ^ b) # 6 (0110) XOR
print(~a) # -13 NOT (two's complement)
print(a << 2) # 48 (110000) Left shift
print(a >> 1) # 6 (110) Right shift
# Practical: check if number is even/odd
print(12 & 1) # 0 → even
print(13 & 1) # 1 → odd
# Swap without temp
a, b = 10, 20
a = a ^ b
b = a ^ b
a = a ^ b
print(a, b) # 20, 10# in / not in — test containment
print('h' in 'hello') # True
print('x' not in 'hello') # True
nums = [1, 2, 3, 4, 5]
print(3 in nums) # True
print(6 not in nums) # True
print('name' in {'name': 'John', 'age': 25}) # True (checks keys)# is / is not — check if SAME object in memory
a = [1, 2, 3]
b = [1, 2, 3]
c = a
print(a == b) # True (same values)
print(a is b) # False (different objects!)
print(a is c) # True (same object)
# Always use 'is' for None, True, False
x = None
print(x is None) # ✅ Correct
print(x == None) # ⚠️ Works but not PEP 8 recommended
# String interning
a = 'hello'
b = 'hello'
print(a is b) # True (small strings are interned)
a = 'a very long string that probably wont be interned'
b = 'a very long string that probably wont be interned'
print(a is b) # Might be FalseCreate a function `classify_number(n)` that returns a dictionary with: 'even' (bool), 'positive' (bool), 'divisible_by_3' (bool), 'power_of_2' (bool), 'binary' (string of binary digits). Use bitwise & for even check, // and % for divisibility, and bit manipulation for power of 2 check (n & (n-1) == 0). Test with n=16, n=7, n=-4, n=0.