Practice The elif Statement - 4.4 | Control Flow – if, elif, else | Python Programming Language
K12 Students

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skills—perfect for learners of all ages.

4.4 - The elif Statement

Enroll to start learning

You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.

Learning

Practice Questions

Test your understanding with targeted questions related to the topic.

Question 1

Easy

Write a simple program using elif to define a traffic light system that prints 'Stop', 'Caution', or 'Go' based on the light color.

💡 Hint: Use elif to check the other colors after the first condition.

Question 2

Easy

Create a program that checks if a number is even or odd using if and elif.

💡 Hint: Start with an if condition for even, and then use elif for odd.

Practice 4 more questions and get performance evaluation

Interactive Quizzes

Engage in quick quizzes to reinforce what you've learned and check your comprehension.

Question 1

What does elif do in Python?

  • Checks if the given condition is true
  • Catches errors
  • Allows checking additional conditions after an if statement

💡 Hint: Remember the purpose of elif is to handle multiple conditions!

Question 2

The elif statement is used when the first if condition is?

  • True
  • False

💡 Hint: Think about the order of execution in control flow.

Solve 3 more questions and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

Create a program that simulates a vending machine, which checks for selected items and returns prices based on the item chosen using elif statements.

💡 Hint: Use elif for each item option.

Question 2

Design a quiz application that evaluates answers and gives a feedback score based on various criteria using nested if-elif conditions.

💡 Hint: Consider how multiple conditions can affect the feedback.

Challenge and get performance evaluation