Font size
WorksheetsPython Module , OOPs & Emerging Techonolgies
Total questions: 45
Worksheet time: 30mins
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
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,12,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.
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
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
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()
Error, invalid syntax for object declaration
Nothing is printed
5
Error, private class member can’t be accessed in a subclass
What do Objects represent?
Uniqueness
Identity
Instance
Class
What refers to the behavior of the class
Attribute
Class
Object
Method
what is self?
Self represents the instance of the class in the class
Binds the Attr and methods
A default thing in classes with no use
None of the Above
How to call a method in OOPs?
Obj.method
Obj.method()
Method(object)
Method.object
Syntax to create class
class NAME:
class NAME():
class (NAME):
class: Name()
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()
Animal speaks
Dog barks
Error
None
Which of the following is true about the ''__init__'' method in Python?
It must return a value
It is called automatically when a class is instantiated
It can only have one parameter
It is optional in all classes
Which of the following is an example of polymorphism in Python?
Method call
Method overriding
Multiple inheritance
All of the above
Which of the following is NOT an example of polymorphism in Python?
A class inheriting from multiple parent classes.
A method in a child class overriding a method in the parent class.
Using different classes with a common method name
Method Over riding
What is Instantiation in terms of OOP terminology?
Deleting an instance of class
Modifying an instance of class
Copying an instance of class
Creating an instance of class
What is inheritance in Python OOP?
The capability of a class to derive methods from another class
The capability of a class to derive methods from an object
The capability of a class to derive properties from an object
The capability of a class to derive properties from another class
What is encapsulation in Python OOP?
Exposing data and methods directly
Preventing the use of methods
Wrapping data and methods within one unit
Allowing accidental modification of data
What create objects?
Classes
Functions
Methods
Modules
What are classes?
Blueprints/
Prototypes that defines methods and attributes
A thing which creates objects
A set of attributes and methods
A Blueprint of methods
What are Objects
Instances of a Class
Calling of a class
Identity of a class
Usables of a class
What are Attributes
Functions of a class
Variables of a class
Instance of a class
Variables of a code
A programming mechanism that binds together code and the data it manipulates, and that keeps both safe from outside interference and misuse.
Polymorphism
Inheritance
Encapsulation
Object-Oriented Programming
(from Greek meaning “many forms”) is the quality that allows one interface to access a general class of actions.
Polymorphism
Inheritance
Encapsulation
Object-Oriented Programming
Is the process by which one object can acquire the properties of another object.
Polymorphism
Inheritance
Encapsulation
Object-Oriented Programming
Allows us to consider complex ideas while ignoring irrelevant detail that would confuse us.
Abstraction
Encapsulation
Object
Polymorphism
An _________ is an instance or of a copy of a class.
Class
Attribute
Object
Which emerging technology is most commonly linked to secure digital transactions and decentralization?
Block Chain
AR
Drone
IoT
What is the purpose of the super() function in Python's object-oriented programming
It creates object
It defines a subclass
Gets accesses a to parent class/superclass’s methods or attributes
It creates method
Typically, the first parameter of a method within a class is
def
self
class
object
Another name of __init__ method is
Method
inheritance
object
Constructor
The act of confirming and recording new transactions on a blockchain is known as
transactions
deposit
mining
none of above
Following are the examples of a real-world scenario where polymorphism is useful EXCEPT
Vehicle Control System
Bank Transaction
Health System
Inheriting properties
Check the code and type the answer. What is the name of the class?
(a)
Check the code and choose the correct answer. How many object has been created?
0
1
2
3
Check the code and select the correct answer. How many argument has been passed?
0
1
2
3
