Worksheets › Class 9 › Conditions and Loops
Class 9 · Computational Thinking and AI worksheetConditions and Loops
CBSE Computational Thinking and AI. if, elif and else, for loops with range(), while loops, nested loops, tracing and fixing programs. Every sheet has 20 questions in three sections and an answer key, and the questions change every time.
Sample questions
Real questions from this chapter, as the app sets them. Tap Answer to see the answer and working.
Section A · multiple choice
- 1.
list(range(1, 5)) gives:
- [0, 1, 2, 3, 4]
- [2, 3, 4, 5]
- [1, 2, 3, 4, 5]
- [1, 2, 3, 4]
Answer
(d) [1, 2, 3, 4]
- 2.
What does this print? marks = 86 if marks >= 85: print('A') elif marks >= 75: print('B') elif marks >= 60: print('C') else: print('D')
- D
- C
- B
- A
Answer
(d) A
the first true condition wins: 86
- 3.
What does this print? s = 0 for i in range(8, 13, 4): s = s + i print(s)
- 21
- 33
- 20
- 8
Answer
(c) 20
i = 8, 12 (13 is not included)
Section B · short answer
- 4.
What is the difference between a for loop and a while loop?
Answer
A for loop runs over a fixed sequence (like a range); a while loop repeats as long as a condition is True.
- 5.
What does this print? s = 0 for i in range(6, 12): s = s + i * i print(s)
Answer
451
i = 6, 7, 8, 9, 10, 11
Section C · long answer
- 6.
Write a program to print the grade of a student: A for 90 and above, B for 75 to 89, C for 60 to 74 and D below 60.
Answer
if m >= 90: print("A") elif m >= 75: print("B") elif m >= 60: print("C") else: print("D").
Fresh sheets for your child
In the app, every Conditions and Loops sheet is new: the app remembers the questions your child has already had and leaves them out. Print the sheet as a PDF, or use notebook mode and write the answers in a notebook.
Coming soon for Android and iPhone.