Python-If-else_Questions
Python-If-else_Questions
even.
Q2 Write a program that takes three numbers as input and prints the largest of the three.
Q3 Write a program to check if a given year is a leap year. A leap year is divisible by 4 but not by 100
unless it is also divisible by 400.
Q4 Write a program that takes a percentage (integer) as input and prints the corresponding grade based
on the following criteria:
>= 90: Grade A
>= 80: Grade B
>= 70: Grade C
>= 60: Grade D
< 60: Grade F
Q6 Write a basic calculator program that takes two numbers and an operator (+, -, *, /) as input and
performs the specified operation. Print the result based on the operation.
Q7 Write a program that takes a number as input and checks whether it is positive, negative, or zero.
Q8 Write a program that checks if a username and password entered by the user match the pre-set values
username = "admin" and password = "1234". If both match, print "Login Successful", otherwise print
"Login Failed".
Q9 Write a program that takes three sides of a triangle as input and checks if those sides form a valid
triangle. A triangle is valid if the sum of any two sides is greater than the third side.
Check conditions like a + b > c, b + c > a, and a + c > b.
Q10 Write a program that calculates the Body Mass Index (BMI) based on user input for weight (in
kilograms) and height (in meters). Then categorize the BMI into:
Q11 Write a program that calculates the discount for a product based on its price:
Q12 Write a program that takes the name of a month as input and prints the number of days in that
month. Consider leap years for February.
Q13 Write a program that simulates a simple ATM. The user should be able to:
Check balance
Deposit money
Withdraw money (ensure the balance doesn't go negative) Use an if-else structure to handle the user's
www.regexsoftware.com | [email protected]
choices.
Q14 Write a program that categorizes a given age into different groups:
Q15 Write a program that takes an integer (1-7) as input and prints the corresponding day of the week (1
for Monday, 2 for Tuesday, etc.).
www.regexsoftware.com | [email protected]