Real-Life Analogy
• Example:
•"If it's raining, I’ll take an umbrella. Else, I’ll go
without it."
• Conditional logic is used in daily life, and in
programming too!
3.
What Are ConditionalStatements?
• if: Checks the first condition
• elif: Checks another condition if previous ones
fail
• else: Executes when no above conditions are
true
Example: if-else
• age= 16
• if age >= 18:
• print('You can vote')
• else:
• print('Too young to vote')
7.
Example: if-elif-else
• marks= 75
• if marks >= 90:
• print('Grade: A')
• elif marks >= 60:
• print('Grade: B')
• else:
• print('Grade: C')
8.
Using Logical Operators
•temperature = 30
• humidity = 70
• if temperature > 25 and humidity > 60:
• print('It feels hot and humid!')
9.
Practice Questions
• 1.Check if a number is positive, negative, or
zero
• 2. Check if a year is a leap year
• 3. Grade calculator
• 4. Classify age as child, adult, or senior
10.
Summary
• - Useif, elif, else for decision-making
• - Combine with logical operators for more
power
• - Indentation is crucial in Python!