# a) Arithmetic Operators
print("--- Arithmetic Operators ---")
num1 = 10
num2 = 3
print(f"Addition: {num1 + num2}")
print(f"Subtraction: {num1 - num2}")
print(f"Multiplication: {num1 * num2}")
print(f"Division: {num1 / num2}")
print(f"Floor Division: {num1 // num2}")
print(f"Modulus: {num1 % num2}")
print(f"Exponentiation: {num1 ** num2}")
# b) Logical Operators
print("\n--- Logical Operators ---")
is_true = True
is_false = False
print(f"AND: {is_true and is_false}")
print(f"OR: {is_true or is_false}")
print(f"NOT: {not is_true}")
# c) Relational Operators
print("\n--- Relational Operators ---")
val1 = 5
val2 = 10
print(f"Equal to: {val1 == val2}")
print(f"Not equal to: {val1 != val2}")
print(f"Greater than: {val1 > val2}")
print(f"Less than: {val1 < val2}")
print(f"Greater than or equal to: {val1 >= val2}")
print(f"Less than or equal to: {val1 <= val2}")
# d) Conditional Operators (often referred to as Assignment Operators combined with arithmetic)
# Note: Python does not have a distinct "conditional operator" category in the same way some
languages do.
# This section demonstrates assignment operators which are often used conditionally.
print("\n--- Assignment Operators (often used conditionally) ---")
x=5
x += 3 # x = x + 3
print(f"x after +=: {x}")
x -= 2 # x = x - 2
print(f"x after -=: {x}")
x *= 4 # x = x * 4
print(f"x after *=: {x}")
# e) Bitwise Operators
print("\n--- Bitwise Operators ---")
a = 6 # Binary: 0110
b = 3 # Binary: 0011
print(f"Bitwise AND: {a & b}") # 0010 (2)
print(f"Bitwise OR: {a | b}") # 0111 (7)
print(f"Bitwise XOR: {a ^ b}") # 0101 (5)
print(f"Bitwise NOT (of a): {~a}") # -7 (depends on system's integer representation)
print(f"Left Shift (a << 1): {a << 1}") # 1100 (12)
print(f"Right Shift (a >> 1): {a >> 1}") # 0011 (3)
# f) Ternary Operator (Conditional Expression)
print("\n--- Ternary Operator ---")
age = 20
status = "Adult" if age >= 18 else "Minor"
print(f"Status: {status}")