WorksheetsPython Quiz Infytq
Total questions: 10
Worksheet time: 9mins
Which of the following about a dictionary is false?
The value of a dictionary can be accessed using keys
The keys of a dictionary can be accessed using values
Dictionaries are unordered
Dictionaries are mutable
John is visiting a zoo. After roaming for sometime, he finds that he has lost his way. John wants to reach the entry/exit gate. He remembers ‘Vans Ice-Cream’, a landmark which he saw while strolling in the zoo. John finds that there are 3 ways to reach Vans Ice-Cream from his current location and from Vans Ice-Cream there are 4 ways to reach the entry/exit gate.
Considering the above scenario, identify the most suitable data structure that can represent all possible ways to reach the entry/exit gate from John’s current location?
Graph
Tree
Stack
Queue
Find Output?
s = “The youngest pope was 11 years old”
x = s.split()
print(x[-3] + “ ” + x[-1] + “ ” + x[2] + “s”)
11 old
11 years old
11 old pope
11 old popes
Find the output?
from itertools import compress
print(list(compress([‘TOY’, ‘HONEY’, ‘GOOD’, ‘CAT’, ‘CHERRY’], [0,0,1,1,0])))
Error
[‘TOY’, ‘HONEY’, ‘CHERRY’]
[‘GOOD’, ‘CAT’]
None of the above
Find the Output
True
False
None
Error
What will be the output of the following Python code snippet?
(a)
What will be the output of the following Python code snippet?
(a)
Consider the Python code above.
Assume that the necessary imports have been done.
Which of the following statement(s) is/are TRUE?
i) Class Circle cannot be instantiated as it does not implement the set_color() method
ii) The above code will not compile because class Shape has two abstract methods
Both i) and ii) are True
Neither of i) or ii) is True
Only i) is True
Only ii) is True
Consider the following Python code. Choose the correct option with respect to the number of static, instance and local variables in ClassOne:
0 static variable, 3 instance variables, 2 local variables
1 static variable, 2 instance variables, 2 local variables
1 static variable, 3 instance variables, 1 local variables
2 static variable, 2 instance variables, 1 local variables
Find Output
def show(name, msg):
print(name, “ wishes you ”, msg)
show(“CodeChefSec”, “Happy Coding”)
Nothing Prints
Error
CodeChefSec wishes you Happy Coding
None of the above
