Built-in modules and library functions Theory + PYQ
What We'll Learn
A quick overview of today's lecture
Built-in modules and library functions Theory + PYQ
COMBINED THEORY + PYQ (single slot).
Concept ID: U1_MODULES_LIBRARY.
Primary Sub-subtopic: Built-in modules and library functions.
Question-bank grouping: Functions and Modules.
Teach the core theory first, then spend the remainder of the lecture on previous-year questions whose concept_ids include U1_MODULES_LIBRARY.
Key things we'll cover
Built-in modules and library functions
PYQ references used by both prompts11 included0 excluded
Flagged questions are excluded from both Study Notes and PPT references until corrected in Paper Analyzer.
Included
ID 6509 · 2021 · 1 mark(s)
What will be the output of the following code?
import random
List=["Delhi","Mumbai","Chennai","Kolkata"]
for y in range(4):
x = random.randint(1,3)
print(List[x],end="#")
a) Delhi#Mumbai#Chennai#Kolkata#
b) Mumbai#Chennai#Kolkata#Mumbai#
c) Mumbai# Mumbai #Mumbai # Delhi#
d) Mumbai# Mumbai #Chennai # Mumbai
Functions and Modules → Built-in modules and library functions
Included
ID 6103 · 2023 · 1 mark(s)
Assertion (A) : To use a function from a particular module, we need to import the module.
Reason (R) : import statement can be written anywhere in the program, before using a function from that module.
(a) Both (A) and (R) are true and (R) is the correct explanation for (A).
(b) Both (A) and (R) are true and (R) is not the correct explanation for (A).
(c) (A) is true but (R) is false.
(d) (A) is false but (R) is true.
Functions and Modules → Built-in modules and library functions
Included
ID 6578 · 2023 · 1 mark(s)
What possible output(s) will be obtained when the following code is executed?
import random
myNumber=random.randint(0,3)
COLOR=["YELLOW","WHITE","BLACK","RED"]
for I in range(1,myNumber):
print(COLOR[I],end="*")
print()
a) RED*
WHITE*
BLACK*
b) WHITE*
BLACK*
c) WHITE* WHITE*
BLACK* BLACK*
d) YELLOW*
WHITE*WHITE*
BLACK* BLACK* BLACK*
Functions and Modules → Built-in modules and library functions
Included
ID 6586 · 2023 · 1 mark(s)
Assertion(A): Python Standard Library consists of various modules.
Reasoning(R): A function in a module is used to simplify the code and avoids repetition.
a) Both A and R are true and R is the correct explanation for A
b) Both A and R are true and R is not the correct explanation for A
c) A is True but R is False
d) A is false but R is True
Functions and Modules → Built-in modules and library functions
Included
ID 6335 · 2024 · 1 mark(s)
Predict the output of the following Python statements :
>>>import statistics as s
>>>s.mode ([10, 20, 10, 30, 10, 20, 30])
(A) 30
(B) 20
(C) 10
(D) 18.57
Functions and Modules → Built-in modules and library functions
Included
ID 6336 · 2024 · 1 mark(s)
Which of the following output will never be obtained when the given code is executed ?
import random
Shuffle = random.randrange(10)+1
Draw = 10*random.randrange(5)
print ("Shuffle", Shuffle, end="#")
print ("Draw", Draw)
(A) Shuffle 1 # Draw 0
(B) Shuffle 10 # Draw 10
(C) Shuffle 10 # Draw 0
(D) Shuffle 11 # Draw 50
Functions and Modules → Built-in modules and library functions
Included
ID 6638 · 2024 · 2 mark(s)
Identify the correct output(s) of the following code. Also write the minimum and the maximum possible values of the variable b.
import random
a="Wisdom"
b=random.randint(1,6)
for i in range(0,b,2):
print(a[i],end='#')
a) W#
b) W#i#
c) W#s#
d) W#i#s#
Functions and Modules → Built-in modules and library functions
Included
ID 6661 · 2025 · 1 mark(s)
State if the following statement is True or False:
Using the statistics module, the output of the below statements will be 20:
import statistics
statistics.median([10, 20, 10, 30, 10, 20, 30])
Functions and Modules → Built-in modules and library functions
Included
ID 6671 · 2025 · 1 mark(s)
What possible output is expected to be displayed on the screen at the time of execution of the Python program from the following code?
import random
L=[10,30,50,70]
Lower=random.randint(2,2)
Upper=random.randint(2,3)
for K in range(Lower, Upper+1):
print(L[K], end="@")
a) 50@70@
b) 90@
c) 10@30@50@
d) 10@30@50@70@
Functions and Modules → Built-in modules and library functions
Included
ID 6396 · 2025 · 2 mark(s)
Identify the correct possible output(s) of the following code segment. Also write the minimum and the maximum possible values of the variable b.
import random
s="War and Peace"
a=len(s)//2
for i in range(4):
b=random.randrange(i,a)
print(s[b],end='+')
(A) n+P+d+a+
(B) W+r+n+n+
(C) e+r+W+a+
(D) a+P+e+r+
Functions and Modules → Built-in modules and library functions
Included
ID 6245 · 2026 · 2 mark(s)
What possible output(s) from the given options will NOT be displayed when the following code is executed ? Also, mention, for how many iterations the for loop in the given code will run ?
import random
a = [1,2,3,4,5,6]
for i in range(4):
j = random.randrange(i,5)
print(a[j],end='-')
print()
Options :
(A) 3-4-5-4-
(B) 2-2-4-5-
(C) 4-3-3-5-
(D) 5-1-2-4-
Functions and Modules → Built-in modules and library functions