Practice The IF Statement - 21.1 | 21. IF, FOR, WHILE | CBSE 9 AI (Artificial Intelligence)
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

The IF Statement

21.1 - The IF 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

Question 1 Easy

What will the following code output?

Code Editor - python

💡 Hint: Check if age is 18 or older.

Question 2 Easy

Write an IF statement that checks if the number is positive.

💡 Hint: Think about using the greater than operator.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

What does an IF statement do?

Executes code unconditionally
Executes code based on a condition
Stops execution of the program

💡 Hint: Think about what makes the IF statement distinct.

Question 2

True or False: The ELSE statement only executes if the IF condition is true.

True
False

💡 Hint: Reflect on what the purpose of ELSE is.

1 more question available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

Create a nested IF statement that checks whether a user can attend college based on both their age and their high school diploma status. Write the conditional structure.

💡 Hint: Consider how you can check two separate conditions effectively.

Challenge 2 Hard

Write a program that continuously prompts for a user’s age until they provide a correct response (18 or older) and informs them of their eligibility to vote.

💡 Hint: Think about how to use a loop to keep asking.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.