Skip to Content
Practice CornerIf Statements

If Statements

Conditional statements allow programs to make decisions based on specific conditions. The if statement in Python is one of the most basic and essential tools for implementing logic in your code. Here are some beginner-friendly exercises to practice conditional statements.

1. Check Number Type

PygroundTry It Out

Input a number and check if it is positive, negative, or zero.

Output:

2. Voting Eligibility

PygroundTry It Out

Input your age and check if you are eligible to vote (age 18 or older).

Output:

3. Even or Odd

PygroundTry It Out

Input a number and check if it is even or odd.

Output:

4. Find Largest Number

PygroundTry It Out

Input three numbers and find the largest among them.

Output:

5. Leap Year Check

PygroundTry It Out

Input a year and check if it is a leap year.

Output:

6. Pass or Fail

PygroundTry It Out

Input your marks and check if you passed or failed (passing marks = 40).

Output:

7. Check Divisibility

PygroundTry It Out

Input two numbers and check if the first is divisible by the second.

Output:

8. Temperature Check

PygroundTry It Out

Input the temperature in Celsius and check if it's cold (below 15°C), warm (15°C-25°C), or hot (above 25°C).

Output:

9. Vowel or Consonant

PygroundTry It Out

Input a character and check if it is a vowel or a consonant.

Output:

10. Multiple of 5

PygroundTry It Out

Input a number and check if it is a multiple of 5.

Output:

Last updated on