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

Practice Questions

Test your understanding with targeted questions related to the topic.

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.

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 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.

Solve 1 more question and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

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.

Question 2

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.

Challenge and get performance evaluation