Practice Multiple Conditions Using Elif (8.1.3) - Control Flow - Data Structures and Algorithms in Python
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Multiple Conditions Using Elif

Practice - Multiple Conditions Using Elif

Learning

Practice Questions

Test your understanding with targeted questions

Question 1 Easy

What will the following code print if num is 5? if num > 10: print('Greater') else: print('Lesser')

💡 Hint: Consider the condition given.

Question 2 Easy

Write an if statement to check if a value x is positive.

💡 Hint: Use the greater than operator.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

What does the elif keyword do?

Checks the first condition
Checks additional conditions
Ends the conditional block

💡 Hint: Think of it as 'else if'.

Question 2

True or False: The else statement is mandatory in an if-elif-else structure.

True
False

💡 Hint: Remember that we can end with `elif`.

1 more question available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

You are writing a program to determine a passenger's flight fare based on the following rules: If the passenger is under 12 years or over 65 years, fare is half; If the passenger is between 12 and 64 inclusive, fare is full. Write a function to implement this.

💡 Hint: Think of using multiple conditions in the if statement.

Challenge 2 Hard

Write a Python program that categorizes temperatures as 'Cold', 'Warm', 'Hot', and 'Extreme' based on the following scale: Below 0 - Cold, 0-20 - Warm, 21-35 - Hot, Above 35 - Extreme.

💡 Hint: Use elif to check between multiple ranges.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.