Rohit Verma’s Post

Decision Making (if-else) Today I learned how Python makes decisions using conditions. This is one of the most important concepts in programming. 🔹 What is Decision Making? It allows a program to take actions based on conditions. 🔸 if Statement Used to execute code only if a condition is true. Example: age = 18 if age >= 18:   print("You can vote") 🔸 if-else Statement Executes one block if condition is true, otherwise another block. Example: age = 16 if age >= 18:   print("Eligible") else:   print("Not eligible") 🔸 if-elif-else Statement Used when we have multiple conditions. Example: marks = 75 if marks >= 90:   print("Grade A") elif marks >= 60:   print("Grade B") else:   print("Grade C") 💡 Key Learning: Indentation is very important in Python. It defines the structure of code. 🧪 Practice Task: Create a program that checks whether a number is even or odd. 🎯 Interview Question: What is the difference between if and elif? Answer: "if" checks a condition independently, while "elif" is used to check multiple conditions in sequence. #Python #Learning #CodingJourney #Day4 #Programming #SDET Masai #dailylearning #masaiverse

To view or add a comment, sign in

Explore content categories