Python 1 Nov 2023
Python 1 Nov 2023
2. Create a Python program that prompts the user for their age. If the age is less than 18, print
"You are a minor," otherwise print "You are an adult" using an if-else statement.
3. Write a program that takes a number as input and prints "Positive" if it's greater than 0,
"Negative" if it's less than 0, and "Zero" if it's equal to 0 using if-elif-else.
4. Create a Python program that checks if a number is divisible by both 2 and 3. If it is, print
"Divisible by 2 and 3," otherwise print "Not divisible by both" using if-else.
5. Write a program that determines if a given year is a leap year. If it is, print "Leap year,"
otherwise print "Not a leap year" using if-else.
6. Create a program that takes three numbers as input and prints the largest of them using nested
if-else statements.
7. Write a program that asks the user to enter a character and checks if it is a vowel (a, e, i, o, u)
or a consonant using if-else.
8. Create a program that takes a number as input and checks if it's in the range of 10 to 50
(inclusive). Print "In range" if it is, and "Out of range" if it's not using if-else.
9. Write a program that takes two numbers as input and determines if they are equal, greater, or
less than each other using if-elif-else statements.
10. Create a program that takes a grade (A, B, C, D, F) as input and prints the corresponding
message ("Excellent," "Good," "Satisfactory," "Pass," "Fail") using if-elif-else statements.