What will be the output of the Python code above?
Anonymous Quiz
31%
[โabโ, โcdโ]
61%
[โABโ, โCDโ]
5%
[None, None]
4%
none of the mentioned
What happens if a class does not implement __str__()?
Anonymous Quiz
24%
Instances of that class will use __repr__() method of the class
29%
Instances of that class will output the name of the class when printed
26%
Instances of that class cannot be printed
21%
Instances of that class will output the dictionary with all instance attributes when printed
๐2
Code snippet:
from functools import reduce
numbers = [1, 2, 3]
reduce(lambda x, y: x + y, numbers)
Which of the following is the same as list(map(lambda x: x**-1, [1, 2, 3]))?
Anonymous Quiz
39%
[x**-1 for x in [(1, 2, 3)]]
22%
[1/x for x in [(1, 2, 3)]]
18%
[1/x for x in (1, 2, 3)]
21%
error
Which of the following lines of code will not show a match?
Anonymous Quiz
26%
>>> re.match(โab*โ, โaโ)
20%
>>> re.match(โab*โ, โabโ)
23%
>>> re.match(โab*โ, โabbโ)
31%
>>> re.match(โab*โ, โbaโ)
๐1
What will be the output of the Python code above?
Anonymous Quiz
63%
[0]
16%
[1]
13%
[1, 0]
7%
[0, 1]
What will be the output of the code above?
Anonymous Quiz
7%
abc def
58%
ABC DEF
17%
Abc def
19%
Abc Def
๐1
Code snippet:
class A:
@staticmethod
def a(x):
print(x)
A.a(100)
What will be the output of the code snippet?
Anonymous Quiz
14%
Error
15%
Warning
58%
100
13%
No output
What will be the output of the code snippet?
Anonymous Quiz
30%
0 1 2 3
5%
0 1 2 2
2%
3 3 3 3
43%
0 0 0 0
20%
error
Code snippet:
class Demo:
def __init__(self):
self.a = 1
self.__b = 1
def display(self):
return self.__b
obj = Demo()
print(obj.__b)
What will be the output of the code?
Anonymous Quiz
14%
The program has an error because there isnโt any function to return self.a
22%
The program has an error because b is private and display(self) is returning a private member
24%
The program has an error because b is private and hence canโt be printed
39%
The program runs fine and 1 is printed