wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz1_HPB2021_2010t1

Total questions: 10

Worksheet time: 20mins

Name
Class
Date
1.

What is the output of the following code:

x = 3

if 2 > x :

print 'First'

else :

print 'Second'

if 2 > x :

print 'Third'

print 'Fourth'

print 'Fifth'

a)

Second

Fourth

Fifth

b)

First

Second

Third

Fourth

Fifth

c)

Fifth

d)

First

Third

Fifth

2.

1. Which of the below statements will create a Python list?

a)

list1 = list()

b)

list1 = []

c)

list1 = list([1, 2, 3])

d)

all of the mentioned

3.

If list_example is [2, 33, 222, 14, 25], What is list_example[:-1]?

a)

Error

b)

25

c)

[2, 33, 222, 14]

d)

[25, 14, 222, 33, 2]

4.

Find the output of the following Python code snippet:

print 'ab cd-ef'.title(),

a)

Ab cd-ef

b)

Ab Cd-ef

c)

Ab Cd-Ef

d)

None of the mentioned

5.

Find the output of the following Python code snippet?

print('abcd'.translate({97: 98, 98: 99, 99: 100}))

a)

bcde

b)

abcd

c)

error

d)

none of the mentioned

6.

Shortly explain why the output of the following Python code is 16?

count={}

count[(1,2,4)] = 5

count[(4,2,1)] = 7

count[(1,2)] = 6

count[(4,2,1)] = 2

tot = 0

for i in count:

tot=tot+count[i]

print(len(count)+tot)


output:16

4 lines
7.

Which of the statements about dictionary values is false?

a)

More than one key can have the same value

b)

The values of the dictionary can be accessed as dict[key]

c)

Values of a dictionary must be unique

d)

Values of a dictionary can be a mixture of letters and numbers

8.

What happens when you run the code and what will be the output of the following Python code?


i = 1

while False:

if i%2 == 0:

break

print(i)

i += 2

4 lines
9.

What arithmetic operators cannot be used with strings?

a)

+

b)

*

c)

-

d)

All of the mentioned

10.

What will be the output of the following Python code?


>>>str1="helloworld"

>>>str1[::-1]

a)

dlrowolleh

b)

hello

c)

world

d)

helloworld