Skip to content
Question 80 of 97

Q.Name the Python Library modules which need to be imported to invoke the following functions:

(i) cos()
(ii) randint()
Sikkim CbseCBSE Class XII Board 2020Subjective· 1mImportance★★★★★
82% · 80/97 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

cos() belongs to the math module and randint() belongs to the random module — both are standard-library modules that must be imported before the functions can be called.

Concept — why functions live in modules

Python keeps its core language small. Specialised functions are grouped into standard-library modules, and a program must explicitly import a module before using anything inside it. This keeps the namespace clean and makes every dependency visible at the top of the file.

  • cos() is a trigonometric function, so it lives with the other mathematical functions in the math module.
  • randint() generates pseudo-random integers, so it lives with the other random-number tools in the random module.

Working code

import math
import random

print(math.cos(0))           # cosine of 0 radians
print(random.randint(1, 6))  # random integer N with 1 <= N <= 6 (both ends included)

Expected output (the second line is any integer from 1 to 6):

1.0
4

Both functions can also be imported directly:

from math import cos …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.