Font size
Worksheetspython modules
Total questions: 20
Worksheet time: 10mins
What is a library in python?
COLLECTION OF FILES
COLLECTION OF MODULES
IT IS SUBPROGRAM
NAME OF A FILE
exp(),floor()belongs which module?
cmath.py
urlib.py
math.py
statistics.py
What will be the output of the following
from import factorial
print(math.factorial(5))
25
10
120
error bcz factorial is not a module in math
Which of the statements is used to import all names from a module into the current calling module
import
from
dir()
import*
Suppose a function called add() is defined in a module called adder.py. Which of the following code snippets correctly show how to import and use the add() function? Select all that apply.
import add from adder
result = add(2, 3)
from adder import add
result = add(2, 3)
from adder import add
result = adder.add(2, 3)
import add
result = adder.add(2, 3)
This code is equivalent to
random.randint(1,11)
random.randint(1,10)
random.randrange(1,11,1)
random.randrange(1,10,1)
Name the keyword used to define a function.
define
def
function
fu
Which one is not true about function?
It breaks the large program into small modules.
It avoids repetition.
It makes code reusable.
It makes the program unorganized.
(a) which function helps to display all information including docstring ,function name and constant in a module.
random.randrange(6)
0,1,2,3,4,5,6
1,2,3,4,5,6
0,1,2,3,4,5
1,2,3,4,5
random.randint(3,8)
4,5,6,7
3,4,5,6,7
3,4,5,6,7,8
0,1,2,3,4,5,6,7,8
random.random() generates a floating point number between _____ and ______
1 and 2
1 and 0
0 and 1
0 and 10
Which function truncates the fractional part of given number and returns only the integer or whole part.
int()
round()
oct()
hex()
docstrings
single quoted comments
double quoted comments
triple quoted comments
hash tagged comments
What will be the output of the following Python code?
def cube(x):
return x * x * x
x = cube(3)
print (x)
9
3
27
30
What are the two main types of functions?
Custom function
Built-in function & User defined function
User function
System function
