Python Modules Interview Questions: MCQs Python

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

 

Python Modules Interview Questions

 

 

Which of the following is true about the top-down design process ??

a) The details of a program design are addressed before the overall design
b) Only the details of the program are addressed
c) The overall design of the program is addressed before the details
d) Only the design of the program is addressed

 

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

random.choice(‘sun’)

a) sun
b) u
c) either s, u or n
d) error

 

What is a string literal denoted by triple quotes for providing the specifications of certain program elements ??

a) Interface
b) Modularity
c) Client
d) Docstring

 

What will be the output of the following Python code ??

import random
random.choice([10.4, 56.99, 76])

a) Error
b) Either 10.4, 56.99 or 76
c) Any number other than 10.4, 56.99 and 76
d) 56.99 only

 

Python Modules Interview Questions

 

Program code making use of a given module is called a ______ of the module ??

a) Client
b) Docstring
c) Interface
d) Modularity

 

What will be the output of the following Python ??

import random
random.choice(2,3,4)

a) An integer other than 2, 3 and 4
b) Either 2, 3 or 4
c) Error
d) 3 only

 

Which of the following is not an advantage of using modules ??

a) Provides a means of reuse of program code
b) Provides a means of dividing up tasks
c) Provides a means of reducing the size of the program
d) Provides a means of testing individual parts of the program

 

The output of the following Python code is either 1 or 2 ??

import random
random.randint(1,2)

a) True
b) False

 

Python Modules Interview Questions

 

Which of these definitions correctly describes a module ??

a) Denoted by triple quotes for providing the specification of certain program elements
b) Design and implementation of specific functionality to be incorporated into a program
c) Defines the specification of how it is to be used
d) Any program that reuses code

 

To include the use of functions that are present in the random library, we must use the option ??

a) import random
b) random.h
c) import.random
d) random.random

 

Which of the following can be used to create a symbolic link ??

a) os.symlink()
b) os.symb_link()
c) os.symblin()
d) os.ln()

 

What will be the output of the functions ??

import turtle
t=turtle.Pen()
for i in range(0,3):
t.forward(100)
t.left(120)
t.back(100)
for i in range(0,3):
t.forward(100)
t.left(120)

a) Error
b) Two triangles, joined by a straight line
c) Two triangles, joined at one vertex
d) Two separate triangles, not connected by a line

 

Python Modules Interview Questions

 

The output of the function len(sys.argv) is ??

a) Error
b) 1
c) 0
d) Junk value

 

What will be the output of the code ??

import turtle
t=turtle.Pen()
for i in range(0,5):
t.left(144)
t.forward(100)

a) Trapezium
b) Parallelepiped
c) Tetrahedron
d) Star

 

Which of the following can be used to create a directory ??

a) os.mkdir()
b) os.creat_dir()
c) os.create_dir()
d) os.make_dir()

 

Read More

Leave a Comment

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

error: Content is protected !!