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

Python 1 Nov 2023

The document contains 10 practice questions involving if, if-else and nested if-else statements in Python. The questions cover topics such as checking even/odd numbers, age ranges, positive/negative/zero values, divisibility, leap years, maximum of 3 numbers, vowels/consonants, ranges and comparing two numbers. The document provides sample code templates to write programs for each question using the appropriate conditional statements.

Uploaded by

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

Python 1 Nov 2023

The document contains 10 practice questions involving if, if-else and nested if-else statements in Python. The questions cover topics such as checking even/odd numbers, age ranges, positive/negative/zero values, divisibility, leap years, maximum of 3 numbers, vowels/consonants, ranges and comparing two numbers. The document provides sample code templates to write programs for each question using the appropriate conditional statements.

Uploaded by

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

DATE (1-11-2023)

PRACTICE QUESTIONS ON IF,IF ELSE,NESTED IF ELSE


1. Write a Python program that takes an integer as input and prints "Even" if it's an even number
and "Odd" if it's an odd number using an if-else statement.

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.

You might also like