AI Forever
3 subscribers
1 link
๐ŸŒฑ Beginner โ†’ ๏ฟฝ Intermediate โ†’ ๐Ÿš€ Advanced โ†’ ๐Ÿ† Mastery
Download Telegram
๐ŸŒŸ Day 4: Conditional Statements in Python ๐ŸŒŸ

๐ŸŽฏ Objective:
Learn how to use if, elif, and else statements to make decisions in your code.

---

๐Ÿ“š What Are Conditional Statements?
They allow your program to make decisions based on certain conditions.

age = 18
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")


---

โœ… `if` Statement
Checks a condition. If True, it runs the code inside.

num = 10
if num > 5:
print("The number is greater than 5.")


๐Ÿงญ `else` Statement
Runs when the if condition is False.

num = 3
if num > 5:
print("The number is greater than 5.")
else:
print("The number is not greater than 5.")


๐Ÿ”€ `elif` Statement
Use it to check multiple conditions.

num = 0
if num > 0:
print("The number is positive.")
elif num == 0:
print("The number is zero.")
else:
print("The number is negative.")


โš ๏ธ Important: Python uses indentation (4 spaces) to define blocks of code. Be consistent!

---

๐Ÿงช Practice Exercises:

1๏ธโƒฃ Check Even or Odd
num = int(input("Enter a number: "))
if num % 2 == 0:
print("The number is even.")
else:
print("The number is odd.")


2๏ธโƒฃ Grade Calculator
score = int(input("Enter your score: "))
if score >= 90:
print("Grade: A")
elif score >= 80:
print("Grade: B")
elif score >= 70:
print("Grade: C")
elif score >= 60:
print("Grade: D")
else:
print("Grade: F")


3๏ธโƒฃ Positive, Negative or Zero
num = int(input("Enter a number: "))
if num > 0:
print("The number is positive.")
elif num == 0:
print("The number is zero.")
else:
print("The number is negative.")


---

๐Ÿ Goal for Today:
โœ”๏ธ Understand how if, elif, and else work
โœ”๏ธ Write decision-based programs
โœ”๏ธ Master proper indentation

#ConditionalStatements #IfElse #PythonBasics #PythonTutorial #CodingLessons #TechEducation #Day4