MCQs Python Modules: Modules MCQs In Python Language

MCQs Python Modules. Multiple Choice Questions related to Modules in Python.

 

MCQs Python Modules

 

 

Which of the following is not a valid namespace ??

a) Global namespace
b) Public namespace
c) Built-in namespace
d) Local namespace

 

Which of the following is equivalent to random.randint(3, 6) ??

a) random.choice([3, 6])
b) random.randrange(3, 6)
c) 3 + random.randrange(3)
d) 3 + random.randrange(4)

 

What is the interval of the value generated by the function random.random(), assuming that the random module has already been imported ??

a) (0,1)
b) (0,1]
c) [0,1]
d) [0,1)

 

Which of the following isn’t true about main modules ??

a) When a python file is directly executed, it is considered the main module of a program
b) Main modules may import any number of modules
c) Special name given to main modules is: __main__
d) Other main modules can import main modules

 

MCQs Python Modules

 

The function random.randint(4) can return only one of the following values. Which ??

a) 4
b) 3.4
c) error
d) 5

 

What will be the output of following code ??

random.seed(3)
random.randint(1,5)
2
random.seed(3)
random.randint(1,5)

a) 3
b) 2
c) Any integer between 1 and 5, including 1 and 5
d) Any integer between 1 and 5, excluding 1 and 5

 

What will be the output of the following Python ??

#mod1
def change(a):
b=[x*2 for x in a]
print(b)
#mod2
def change(a):
b=[x*x for x in a]
print(b)
from mod1 import change
from mod2 import change
#main
s=[1,2,3]
change(s)

a) [2,4,6]

b) [1,4,9]

c) [2,4,6]
[1,4,9]

d) There is a name clash

 

Which of the following is equivalent to random.randrange(3) ??

a) range(3)
b) random.choice(range(0, 3))
c) random.shuffle(range(3))
d) random.select(range(3))

 

MCQs Python Modules

 

Which of the following functions helps us to randomize the items of a list ??

a) seed
b) randomise
c) shuffle
d) uniform

 

All modular designs are because of a top-down design process ??

a) True
b) False

 

Which of the following cannot be returned by random.randrange(4) ??

a) 0
b) 3
c) 2.3
d) none of the mentioned

 

What will be the output of the following Python function if the random module has already been imported ??

random.randint(3.5,7)

a) Error
b) Any integer between 3.5 and 7, including 7
c) Any integer between 3.5 and 7, excluding 7
d) The integer closest to the mean of 3.5 and 7

 

MCQs Python Modules

 

In top-down design every module is broken into same number of submodules ??

a) True
b) False

 

What the does random.seed(3) return ??

a) True
b) None
c) 3
d) 1

 

What will be the output of the following Python function, assuming that the random module has already been imported ??

random.uniform(3,4)

a) Error
b) Either 3 or 4
c) Any integer other than 3 and 4
d) Any decimal value between 3 and 4

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!