wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Module , OOPs & Emerging Techonolgies

Total questions: 45

Worksheet time: 30mins

Name
Class
Date
1.

What is a library in python?

a)

COLLECTION OF FILES

b)

COLLECTION OF MODULES

c)

IT IS SUBPROGRAM

d)

NAME OF A FILE

2.

exp(),floor()belongs which module?

a)

cmath.py

b)

urlib.py

c)

math.py

d)

statistics.py

3.

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*

4.
Which of the following is not an advantage of using modules?
a)
a) Provides a means of reuse of program code
b)
b) Provides a means of dividing up tasks
c)
c) Provides a means of reducing the size of the program
d)
d) Provides a means of testing individual parts of the program
5.
A Python module is a file with the _____ file extension that contains valid Python code.
a)
.pymodule
b)
.py
c)
.module
d)
.pym
6.

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)

7.

This code is equivalent to

a)

random.randint(1,11)

b)

random.randint(1,10)

c)

random.randrange(1,12,1)

d)

random.randrange(1,10,1)

8.

Name the keyword used to define a function.

a)

define

b)

def

c)

function

d)

fu

9.

Which one is not true about function?

a)

It breaks the large program into small modules.

b)

It avoids repetition.

c)

It makes code reusable.

d)

It makes the program unorganized.

10.

random.randrange(6)

a)

0,1,2,3,4,5,6

b)

1,2,3,4,5,6

c)

0,1,2,3,4,5

d)

1,2,3,4,5

11.

random.randint(3,8)

a)

4,5,6,7

b)

3,4,5,6,7

c)

3,4,5,6,7,8

d)

0,1,2,3,4,5,6,7,8

12.

random.random() generates a floating point number between _____ and ______

a)

1 and 2

b)

1 and 0

c)

0 and 1

d)

0 and 10

13.

What will be the output of the following Python code?

def cube(x):

return x * x * x


x = cube(3)

print (x)

a)

9

b)

3

c)

27

d)

30

14.

What are the two main types of functions?

a)

Custom function

b)

Built-in function & User defined function

c)

User function

d)

System function

15.

What will be the output of the following Python code?


class A:

def __init__(self):

self._x = 5


class B(A):

def display(self):

print(self._x)


def main():

obj = B()

obj.display()


main()

a)

Error, invalid syntax for object declaration

b)

Nothing is printed

c)

5

d)

Error, private class member can’t be accessed in a subclass

16.

What do Objects represent?

a)

Uniqueness

b)

Identity

c)

Instance

d)

Class

17.

What refers to the behavior of the class

a)

Attribute

b)

Class

c)

Object

d)

Method

18.

what is self?

a)

Self represents the instance of the class in the class

b)

Binds the Attr and methods

c)

A default thing in classes with no use

d)

None of the Above

19.

How to call a method in OOPs?

a)

Obj.method

b)

Obj.method()

c)

Method(object)

d)

Method.object

20.

Syntax to create class

a)

class NAME:

b)

class NAME():

c)

class (NAME):

d)

class: Name()

21.

What is the output of the following code?

class Animal:

    def speak(self):

        print("Animal speaks")

class Dog(Animal):

    def speak(self):

        print("Dog barks")

d = Dog()

d.speak()

a)

Animal speaks

b)

Dog barks

c)

Error

d)

None

22.

Which of the following is true about the ''__init__'' method in Python?

a)

It must return a value

b)

It is called automatically when a class is instantiated

c)

It can only have one parameter

d)

It is optional in all classes

23.

Which of the following is an example of polymorphism in Python?

a)

Method call

b)

Method overriding

c)

Multiple inheritance

d)

All of the above

24.

Which of the following is NOT an example of polymorphism in Python?

a)

A class inheriting from multiple parent classes.

b)

A method in a child class overriding a method in the parent class.

c)

Using different classes with a common method name

d)

Method Over riding

25.

What is Instantiation in terms of OOP terminology?

a)

Deleting an instance of class

b)

Modifying an instance of class

c)

Copying an instance of class

d)

Creating an instance of class

26.

What is inheritance in Python OOP?

a)

The capability of a class to derive methods from another class

b)

The capability of a class to derive methods from an object

c)

The capability of a class to derive properties from an object

d)

The capability of a class to derive properties from another class

27.

What is encapsulation in Python OOP?

a)

Exposing data and methods directly

b)

Preventing the use of methods

c)

Wrapping data and methods within one unit

d)

Allowing accidental modification of data

28.

What create objects?

a)

Classes

b)

Functions

c)

Methods

d)

Modules

29.

What are classes?

a)

Blueprints/

Prototypes that defines methods and attributes

b)

A thing which creates objects

c)

A set of attributes and methods

d)

A Blueprint of methods

30.

What are Objects

a)

Instances of a Class

b)

Calling of a class

c)

Identity of a class

d)

Usables of a class

31.

What are Attributes

a)

Functions of a class

b)

Variables of a class

c)

Instance of a class

d)

Variables of a code

32.

A programming mechanism that binds together code and the data it manipulates, and that keeps both safe from outside interference and misuse.

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Object-Oriented Programming

33.

(from Greek meaning “many forms”) is the quality that allows one interface to access a general class of actions.

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Object-Oriented Programming

34.

Is the process by which one object can acquire the properties of another object.

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Object-Oriented Programming

35.

Allows us to consider complex ideas while ignoring irrelevant detail that would confuse us.

a)

Abstraction

b)

Encapsulation

c)

Object

d)

Polymorphism

36.

An _________ is an instance or of a copy of a class.

a)

Class

b)

Attribute

c)

Object

37.

Which emerging technology is most commonly linked to secure digital transactions and decentralization?

a)

Block Chain

b)

AR

c)

Drone

d)

IoT

38.

What is the purpose of the super() function in Python's object-oriented programming

a)
  1. It creates object

b)
  1. It defines a subclass

c)
  1.  Gets accesses a to parent class/superclass’s methods or attributes 

d)
  1. It creates method

39.

Typically, the first parameter of a method within a class is

a)

def

b)

self

c)

class

d)

object

40.

Another name of __init__ method is

a)

Method

b)

inheritance

c)

object

d)

Constructor

41.

The act of confirming and recording new transactions on a blockchain is known as

a)

transactions

b)

deposit

c)

mining

d)

none of above

42.

Following are the examples of a real-world scenario where polymorphism is useful EXCEPT

a)

Vehicle Control System

b)

Bank Transaction

c)

Health System

d)

Inheriting properties

43.

Check the code and type the answer. What is the name of the class?

(a)  

44.

Check the code and choose the correct answer. How many object has been created?

a)

0

b)

1

c)

2

d)

3

45.

Check the code and select the correct answer. How many argument has been passed?

a)

0

b)

1

c)

2

d)

3