Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. What is the output of the functions shown below?
ord(65)
ord(‘A’)
Correct Answer is : Error
2. What is the output of the functions shown below?
float(‘-infinity’)
float(‘inf’)
Correct Answer is : –inf
3. Which of the following functions will not result in an error when no arguments are passed to it?
Correct Answer is : float()
4. What is the output of the function shown below?
hex(15)
Correct Answer is : 0xf
5. Which of the following functions does not throw an error?
Correct Answer is : ord(‘ ‘)
6. What is the output of the function:
len(["hello",2, 4, 6])
Correct Answer is : 4
7. What is the output of the function shown below?
oct(7)
oct(‘7’)
Correct Answer is : 0o7
8. _____ represents an entity in the real world with its identity and behaviour.
Correct Answer is : An object
9. _____ is used to create an object.
Correct Answer is : constructor
10. What is the output of the following code?
class test:
def __init__(self,a="Hello World"):
self.a=a
def display(self):
print(self.a)
obj=test()
obj.display()
Correct Answer is : “Hello World” is displayed
11. What is setattr() used for?
Correct Answer is : To set an attribute
12. What is getattr() used for?
Correct Answer is : To access the attribute of the object
13. What is the output of the following code?
class change:
def __init__(self, x, y, z):
self.a = x + y + z
x = change(1,2,3)
y = getattr(x, 'a')
setattr(x, 'a', y+1)
print(x.a)
Correct Answer is : 7
14. What is the output of the following code?
class test:
def __init__(self,a):
self.a=a
def display(self):
print(self.a)
obj=test()
obj.display()
Correct Answer is : Error as one argument is required while creating the object
15. Is the following piece of code correct?
>>> class A:
def __init__(self,b):
self.b=b
def display(self):
print(self.b)
>>> obj=A("Hello")
>>> del obj
Correct Answer is : TRUE
16. What is the output of the following code?
class test:
def __init__(self):
self.variable = 'Old'
self.Change(self.variable)
def Change(self, var):
var = 'New'
obj=test()
print(obj.variable)
Correct Answer is : ‘Old’ is printed
17. What is Instantiation in terms of OOP terminology?
Correct Answer is : Creating an instance of class
18. What is the output of the following code?
class fruits:
def __init__(self, price):
self.price = price
obj=fruits(50)
obj.quantity=10
obj.bags=2
print(obj.quantity+len(obj.__dict__))
Correct Answer is : 13
19. What is the output of the following code?
class Demo:
def __init__(self):
pass
def test(self):
print(__name__)
obj = Demo()
obj.test()
Correct Answer is : __main__
20. The assignment of more than one function to a particular operator is _______