Python Tutorial in Hindi #6 - Conditional Statements

Python Operators Explained | Learn Python in Hindi | Mohit Decodes


In this video, you’ll learn everything about Conditional Statements in Python — the foundation of decision-making in your code. Whether you're writing basic scripts or complex logic, knowing how to use if, elif, and else effectively is crucial.


✅ Topics Covered:

What are Conditional Statements?

Using if, elif, and else

Comparison Operators in conditions

Nested if conditions

Practical examples and syntax walkthrough

Real-world use case: checking eligibility, login system, and more


💡 Ideal for Python beginners, coding students, and interview preparation!


# 🔹 What are Conditional Statements?
# Used to make decisions based on conditions (True / False)

age = 18

if age >= 18:
print("✅ You are eligible to vote.")
else:
print("❌ You are not eligible to vote.")

# 🔹 Example 2: Check positive, negative, or zero
num = int(input("Enter a number: "))

if num > 0:
print("Positive number")
elif num < 0:
print("Negative number")
else:
print("Zero")

# 🔹 Example 3: Even or Odd
n = int(input("Enter any number: "))

if n % 2 == 0:
print("Even number")
else:
print("Odd number")

# 🔹 Example 4: Nested if
marks = int(input("Enter your marks: "))

if marks >= 90:
print("Grade: A+")
elif marks >= 80:
print("Grade: A")
elif marks >= 70:
print("Grade: B")
elif marks >= 60:
print("Grade: C")
else:
print("Grade: F (Fail)")

# 🔹 Example 5: Login System (Nested If)
username = input("Enter username: ")
password = input("Enter password: ")

if username == "admin":
if password == "1234":
print("Login Successful ✅")
else:
print("Wrong Password ❌")
else:
print("Invalid Username ❌")

# 🔹 Example 6: Short Hand if / Ternary Operator
x = 5
y = 10

print("x is greater") if x > y else print("y is greater")

# 🔹 Example 7: Logical Operators
# and, or, not
age = int(input("Enter your age: "))
citizen = input("Are you an Indian citizen? (yes/no): ")

if age >= 18 and citizen.lower() == "yes":
print("You are eligible for voting ✅")
else:
print("You are not eligible ❌")

# 🔹 Example 8: Combining multiple conditions
day = input("Enter day name: ").lower()

if day == "saturday" or day == "sunday":
print("Weekend 😎")
else:
print("Weekday 💻")