0% found this document useful (0 votes)
7 views

Python-If-else_Questions

The document contains a list of programming tasks that involve basic input/output operations and condition checks. Each question requires writing a program to perform specific functions such as checking odd/even numbers, finding the largest of three numbers, determining leap years, and calculating BMI. The tasks are aimed at practicing fundamental programming concepts and logic.

Uploaded by

Amaan Syed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Python-If-else_Questions

The document contains a list of programming tasks that involve basic input/output operations and condition checks. Each question requires writing a program to perform specific functions such as checking odd/even numbers, finding the largest of three numbers, determining leap years, and calculating BMI. The tasks are aimed at practicing fundamental programming concepts and logic.

Uploaded by

Amaan Syed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Q1 Write a program that takes an integer input from the user and checks whether the number is odd or

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

Q5 Write a program that checks if a given letter is a vowel (a, e, i, o, u) or a consonant.

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:

Underweight (BMI < 18.5)


Normal weight (18.5 <= BMI < 24.9)
Overweight (25 <= BMI < 29.9)
Obesity (BMI >= 30)

Use the formula: BMI = weight / (height ** 2)

Q11 Write a program that calculates the discount for a product based on its price:

If price is greater than 1000, discount is 10%


If price is between 500 and 1000, discount is 5%
Otherwise, no discount
Print the final price after applying the discount.

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:

Infant (0-1 year)


Toddler (2-4 years)
Child (5-12 years)
Teenager (13-19 years)
Adult (20-59 years)
Senior (60 years and above)

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]

You might also like