Worksheets › Class 11 › Python Modules: math, random and statistics

Class 11 · Computer Science worksheet

Python Modules: math, random and statistics

CBSE Computer Science. import and from, math functions (sqrt, ceil, floor, pow, fabs, pi), random numbers and their ranges, mean, median and mode. 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.

    A module in Python is:

    1. a data type
    2. an error message
    3. a kind of loop
    4. a file of Python definitions that can be imported and used
    Answer

    (d) a file of Python definitions that can be imported and used

  2. 2.

    What does this program print? import math print(math.ceil(159 / 8))

    1. 22
    2. 40
    3. 20
    4. 21
    Answer

    (c) 20

    ceil() rounds up to a whole number (an int)

  3. 3.

    Which of these can this program NEVER print? import random print(random.randint(20, 24))

    1. 25
    2. 23
    3. 20
    4. 24
    Answer

    (a) 25

    randint(20, 24) gives a whole number from 20 to 24, both included

Section B · short answer

  1. 4.

    What is the difference between import math and from math import sqrt?

    Answer

    import math brings in the module, so functions are used as math.sqrt(); from math import sqrt brings in only sqrt, used directly as sqrt().

  2. 5.

    What does this program print? Give (a) the first line (b) the second. import math print(math.floor(8.5 - 17)) print(math.pow(2, 3))

    Answer

    (a) −9; (b) 8.0

    8.5 − 17 = −8.5; floor() goes down, to the more negative whole number; pow() always gives a float

Section C · long answer

  1. 6.

    Explain three ways of importing a module and using its functions, with examples.

    Answer

    import math → math.sqrt(9); from math import sqrt → sqrt(9); from math import * → sqrt(9) and pi; import math as m → m.sqrt(9).

Fresh sheets for your child

In the app, every Python Modules: math, random and statistics 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 11 Computer Science