# Arithmetic Operators
x = 10
y = 5
sum_result = x + y
diff_result = x - y
mul_result = x * y
div_result = x / y
mod_result = x % y
exp_result = x ** y
floordiv_result = x // y
# Comparison Operators
is_equal = (x == y)
is_not_equal = (x != y)
is_greater = (x > y)
is_less = (x < y)
is_greater_or_equal = (x >= y)
is_less_or_equal = (x <= y)
# Logical Operators
and_result = (x > y) and (y > 0)
or_result = (x > y) or (y < 0)
not_result = not (x > y)
# Assignment Operators
z = 10
z += 5 # z = z + 5
z -= 3 # z = z - 3
z *= 2 # z = z * 2
z /= 2 # z = z / 2
# Identity Operators
a = [1, 2, 3]
b = [1, 2, 3]
is_same = (a is b)
is_not_same = (a is not b)
# Membership Operators
list_example = [1, 2, 3, 4, 5]
is_member = (3 in list_example)
is_not_member = (6 not in list_example)
# Output Results
print("Arithmetic Operations:")
print(f"Sum: {sum_result}, Difference: {diff_result}, Product: {mul_result}")
print(f"Division: {div_result}, Modulus: {mod_result}, Exponent: {exp_result}, Floor Division: {floordiv_result}\n")
print("Comparison Operations:")
print(f"Equal: {is_equal}, Not Equal: {is_not_equal}, Greater: {is_greater}")
print(f"Less: {is_less}, Greater or Equal: {is_greater_or_equal}, Less or Equal: {is_less_or_equal}\n")
print("Logical Operations:")
print(f"AND: {and_result}, OR: {or_result}, NOT: {not_result}\n")
print("Assignment Operations:")
print(f"Final value of z: {z}\n")
print("Identity Operators:")
print(f"Is a same as b: {is_same}, Is a not same as b: {is_not_same}\n")
print("Membership Operators:")
print(f"Is 3 a member of the list: {is_member}, Is 6 not a member: {is_not_member}")
Arithmetic Operations:
Sum: 15, Difference: 5, Product: 50
Division: 2.0, Modulus: 0, Exponent: 100000, Floor Division: 2
Comparison Operations:
Equal: False, Not Equal: True, Greater: True
Less: False, Greater or Equal: True, Less or Equal: False
Logical Operations:
AND: True, OR: True, NOT: False
Assignment Operations:
Final value of z: 12.0
Identity Operators:
Is a same as b: False, Is a not same as b: True
Membership Operators:
Is 3 a member of the list: True, Is 6 not a member: True
is, is not).in, not in).First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.