Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

MCAC0019 Quiz (Based on MODULES & PACKAGES)

Total questions: 15

Worksheet time: 6mins

Name
Class
Date
1.

To put definitions in a file and use them in another scripts, we use_____

a)

packages

b)

functions

c)

modules

d)

project

2.

What will be the output of the following Python code?

from math import factorial

print(math.factorial(5))

a)

120

b)

Nothing is printed

c)

Error, method factorial doesn’t exist in math module

d)

Error, the statement should be: print(factorial(5))

3.

A module consists of

a)

functions

b)

variables

c)

packages

d)

classes

4.

Which of the following is true regarding a package

a)

it is a python file

b)

it is an executable file

c)

it is a directory

d)

ALL

5.

When a package is created, which of the following file it contains

a)

init.py

b)

_init_.py

c)

__init__.py

d)

init

6.

Python has ______ for directories and ______ for files

a)

modules,packages

b)

modules,functions

c)

functions,modules

d)

packages,modules

7.

Two different packages can have modules with same name

a)

May be

b)

Never

c)

Yes

d)

insufficient information

8.

exp(),floor()belongs which module?

a)

cmath.py

b)

urlib.py

c)

math.py

d)

statistics.py

9.

Which of the statements is used to import all names from a module into the current calling module

a)

import

b)

from

c)

dir()

d)

import*

10.
A Python module is a file with the _____ file extension that contains valid Python code.
a)
.pymodule
b)
.py
c)
.module
d)
.pym
11.

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.

a)

import add from adder

result = add(2, 3)

b)

from adder import add

result = add(2, 3)

c)

from adder import add

result = adder.add(2, 3)

d)

import add

result = adder.add(2, 3)

12.

This code is equivalent to

a)

random.randint(1,11)

b)

random.randint(1,10)

c)

random.randrange(1,11,1)

d)

random.randrange(1,10,1)

13.

Name the keyword used to define a function.

a)

define

b)

def

c)

function

d)

fu

14.

(a)   which function helps to display all information including docstring ,function name and constant in a module.

15.

What are the two main types of functions?

a)

Custom function

b)

Built-in function & User defined function

c)

User function

d)

System function