Worksheets › Class 9 › Conditions and Loops

Class 9 · Computational Thinking and AI worksheet

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

Open a printable sample sheet

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

    list(range(1, 5)) gives:

    1. [0, 1, 2, 3, 4]
    2. [2, 3, 4, 5]
    3. [1, 2, 3, 4, 5]
    4. [1, 2, 3, 4]
    Answer

    (d) [1, 2, 3, 4]

  2. 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')

    1. D
    2. C
    3. B
    4. A
    Answer

    (d) A

    the first true condition wins: 86

  3. 3.

    What does this print? s = 0 for i in range(8, 13, 4):     s = s + i print(s)

    1. 21
    2. 33
    3. 20
    4. 8
    Answer

    (c) 20

    i = 8, 12 (13 is not included)

Section B · short answer

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

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

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

More Class 9 Computational Thinking and AI