Worksheets › Class 9 › Python Basics

Class 9 · Computational Thinking and AI worksheet

Python Basics

CBSE Computational Thinking and AI. Operators and precedence, //, % and **, data types and conversion, input() and print(), tracing variables. 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.

    What does print(7 // 2) display?

    1. 4
    2. 1
    3. 3.5
    4. 3
    Answer

    (d) 3

  2. 2.

    What does this print? print(30 * 5 % 6)

    1. 0
    2. 150
    3. 1
    4. −1
    Answer

    (a) 0

    Python does ** first, then * / // %, then + and −, left to right

  3. 3.

    What is the data type of the value of len('abc') in Python?

    1. str
    2. float
    3. int
    4. bool
    Answer

    (c) int

Section B · short answer

  1. 4.

    What is the difference between / and // in Python?

    Answer

    / gives the exact quotient as a float (7 / 2 = 3.5); // gives the whole-number part (7 // 2 = 3).

  2. 5.

    What do these lines print? print(78 // 4) print(78 % 4) Give (a) the first line (b) the second.

    Answer

    (a) 19; (b) 2

    78 = 4 × 19 + 2

Section C · long answer

  1. 6.

    Write a Python program to convert a length in kilometres into metres, and explain each line.

    Answer

    km = float(input()) reads the length; m = km * 1000 converts it; print(m) shows the answer.

Fresh sheets for your child

In the app, every Python Basics 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