Welcome to the Python Full Course in Hindi 2025. In this video, you will learn all about the operators in Python — the essential tools used for performing operations on variables and values.
We will cover arithmetic, comparison, logical, and assignment operators with examples and real-world use cases — explained clearly in Hindi.
Assignment Operators: =, +=, -=, *=, etc.
Understanding operators is crucial for decision-making, loops, and expressions in Python. Watch till the end for a mini challenge to test your understanding.
# -----------------------------------------
# Python Operators - Mohit Decodes (Day 4)
# Arithmetic, Comparison, Logical, Assignment Operators
# -----------------------------------------
# ✅ Arithmetic Operators
a = 10
b = 3
print("Addition:", a + b) # 13
print("Subtraction:", a - b) # 7
print("Multiplication:", a * b) # 30
print("Division:", a / b) # 3.333...
print("Floor Division:", a // b)# 3
print("Modulus:", a % b) # 1
print("Exponent:", a ** b) # 10^3 = 1000
# -----------------------------------------
# ✅ Comparison Operators
# These return True or False
x = 5
y = 10
print("\nComparison Operators:")
print("x == y :", x == y) # False
print("x != y :", x != y) # True
print("x > y :", x > y) # False
print("x < y :", x < y) # True
print("x >= y :", x >= y) # False
print("x <= y :", x <= y) # True
# -----------------------------------------
# ✅ Logical Operators
# and, or, not → Used to combine conditions
p = True
q = False
print("\nLogical Operators:")
print("p and q :", p and q) # False
print("p or q :", p or q) # True
print("not p :", not p) # False
# Example with numbers
age = 20
has_id = True
if age >= 18 and has_id:
print("Eligible to vote")
else:
print("Not eligible")
# -----------------------------------------
# ✅ Assignment Operators
# Used to assign and update values
num = 10
print("\nAssignment Operators:")
num += 5 # num = num + 5
print("After += :", num) # 15
num -= 3 # num = num - 3
print("After -= :", num) # 12
num *= 2 # num = num * 2
print("After *= :", num) # 24
num /= 4 # num = num / 4
print("After /= :", num) # 6.0
num %= 5 # num = num % 5
print("After %= :", num) # 1.0
# -----------------------------------------
# ✅ Mini Practice Task
# Write a program to take 2 numbers and show all arithmetic results.
print("\n--- Mini Challenge ---")
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)
print("Modulus:", a % b)