WorksheetsMCAC0019 Quiz (Based on MODULES & PACKAGES)
Total questions: 15
Worksheet time: 6mins
To put definitions in a file and use them in another scripts, we use_____
packages
functions
modules
project
What will be the output of the following Python code?
from math import factorial
print(math.factorial(5))
120
Nothing is printed
Error, method factorial doesn’t exist in math module
Error, the statement should be: print(factorial(5))
A module consists of
functions
variables
packages
classes
Which of the following is true regarding a package
it is a python file
it is an executable file
it is a directory
ALL
When a package is created, which of the following file it contains
init.py
_init_.py
__init__.py
init
Python has ______ for directories and ______ for files
modules,packages
modules,functions
functions,modules
packages,modules
Two different packages can have modules with same name
May be
Never
Yes
insufficient information
exp(),floor()belongs which module?
cmath.py
urlib.py
math.py
statistics.py
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
(a) which function helps to display all information including docstring ,function name and constant in a module.
What are the two main types of functions?
Custom function
Built-in function & User defined function
User function
System function
