The simplest possible class definition in Python can be expressed as
Anonymous Quiz
17%
class X: return
18%
class X: { }
33%
class X:
32%
class X: pass
Python strings have a property called โimmutability.โ What does this mean?
Anonymous Quiz
10%
Strings in Python can be represented as arrays of chars
69%
Strings in Python canโt be changed
12%
Strings canโt be divided by numbers
10%
You can update a string in Python with concatenation
Which of the following will run without errors?
Anonymous Quiz
55%
round(45.8)
10%
round(6352.898,2,5)
30%
round()
5%
round(7463.123,2,1)
Code snippet:
def example(a):
a = a + '2'
a = a*2
return a
print(example("hello"))
What will be the output of the code snippet above?
Anonymous Quiz
28%
cannot perform mathematical operation on strings
12%
hello2
5%
hello4
54%
hello2hello2
What is the output of the code snippet above?
Anonymous Quiz
4%
0
22%
2.0
38%
2
7%
x
29%
SyntaxError
Code snippet:
from numbers import Number
from decimal import Decimal
from fractions import Fraction
print(isinstance(2.0, Number), end = ' ')
print(isinstance(Decimal('2.0'), Number), end = ' ')
print(isinstance(Fraction(2, 1), Number), end = ' ')
print(isinstance("2", Number), end = ' ')
What is the output of the code snippet above?
Anonymous Quiz
11%
True False True True
18%
True True True True
26%
True False True False
25%
True True True False
11%
False False False False
9%
False True False True
๐ฅ2
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