Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Quiz Infytq

Total questions: 10

Worksheet time: 9mins

Name
Class
Date
1.

Which of the following about a dictionary is false?

a)

The value of a dictionary can be accessed using keys

b)

The keys of a dictionary can be accessed using values

c)

Dictionaries are unordered

d)

Dictionaries are mutable

2.

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?

a)

Graph

b)

Tree

c)

Stack

d)

Queue

3.

Find Output?

s = “The youngest pope was 11 years old”

x = s.split()

print(x[-3] + “ ” + x[-1] + “ ” + x[2] + “s”)

a)

11 old

b)

11 years old

c)

11 old pope

d)

11 old popes

4.

Find the output?

from itertools import compress


print(list(compress([‘TOY’, ‘HONEY’, ‘GOOD’, ‘CAT’, ‘CHERRY’], [0,0,1,1,0])))

a)

Error

b)

[‘TOY’, ‘HONEY’, ‘CHERRY’]

c)

[‘GOOD’, ‘CAT’]

d)

None of the above

5.

Find the Output

a)

True

b)

False

c)

None

d)

Error

6.

What will be the output of the following Python code snippet?

(a)  

7.

What will be the output of the following Python code snippet?

(a)  

8.

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

a)

Both i) and ii) are True

b)

Neither of i) or ii) is True

c)

Only i) is True

d)

Only ii) is True

9.

Consider the following Python code. Choose the correct option with respect to the number of static, instance and local variables in ClassOne:

a)

0 static variable, 3 instance variables, 2 local variables

b)

1 static variable, 2 instance variables, 2 local variables

c)

1 static variable, 3 instance variables, 1 local variables

d)

2 static variable, 2 instance variables, 1 local variables

10.

Find Output


def show(name, msg):

print(name, “ wishes you ”, msg)


show(“CodeChefSec”, “Happy Coding”)

a)

Nothing Prints

b)

Error

c)

CodeChefSec wishes you Happy Coding

d)

None of the above