Skip to content

This textbook is in beta – content is actively being refined. Report issues or suggestions

04.04 Using Standard Modules - Quiz

Check your understanding

  1. Which statement correctly imports the math module?

    • include math
    • import math { data-correct }
    • use math
    • from python import math
  2. What does math.sqrt(25) return?

    • 25
    • 5.0 { data-correct }
    • 625
    • An error
  3. Which function generates a random integer between 1 and 10 (inclusive)?

    • random.random(1, 10)
    • random.randint(1, 10) { data-correct }
    • random.range(1, 10)
    • random.integer(1, 10)
  4. What is the value of math.ceil(4.2)?

    • 4
    • 5 { data-correct }
    • 4.2
    • 4.0
  5. Which function would you use to randomly select one item from a list?

    • random.select()
    • random.pick()
    • random.choice() { data-correct }
    • random.get()
  6. What does math.pi represent?

    • The value 3.14159… { data-correct }
    • A function to calculate pi
    • The variable name for pi
    • An error
  7. What does random.seed(42) do?

    • Generates the number 42
    • Sets the random number generator to produce reproducible sequences { data-correct }
    • Creates 42 random numbers
    • Limits random numbers to 42
  8. Which function calculates the square of a number using the math module?

    • math.square(x)
    • math.pow(x, 2) { data-correct }
    • math.sqrt(x)
    • math.exp(x)
  9. What is a “pure function”?

    • A function that only uses built-in Python features
    • A function that always returns the same output for the same input and has no side effects { data-correct }
    • A function that doesn’t use any modules
    • A function written in pure Python code
  10. What does random.uniform(5.0, 10.0) return?

    • Always 7.5
    • A random integer between 5 and 10
    • A random float between 5.0 and 10.0 { data-correct }
    • A list of numbers from 5 to 10
  11. Which import statement is generally preferred for clarity?

    • from math import *
    • import math { data-correct }
    • import math as m
    • from math import everything
  12. What does math.radians(90) convert?

    • 90 radians to degrees
    • 90 degrees to radians { data-correct }
    • 90 to square root
    • 90 to logarithm