wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Training Day-6 Quiz-6

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Python executes one statement after another from beginning to the end of the program. This is a ________________

a)

Selection Construct

b)

Sequential Construct

c)

Iteration Construct

d)

None of the above

2.

Which of the following statement is not assigning a numerical value 8 to variable X, if original value of X is 0? ?

a)

X = 8

b)

X + = 8

c)

X *= 8

d)

None of the above

3.

Ram wants to create a program to check whether an year is leap year or not. For this he should have a good understanding of ____________

a)

Conditional Statement

b)

for loop

c)

while loop

d)

All of the above

4.

What will be the output of the following Python code?

i = 1

while True:

if i%3 == 0:

break

print(i)

i + = 1

a)

1 2 3

b)

error

c)

1 2

d)

none of the mentioned

5.

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

for i in [1, 2, 3, 4][::-1]:

print (i)

a)

4 3 2 1

b)

error

c)

1 2 3 4

d)

none of the mentioned

6.

What will be the output of the following Python code?

class tester:

def __init__(self, id):

self.id = str(id)

id="224"

 

>>>temp = tester(12)

>>>print(temp.id)

a)

12

b)

224

c)

None

d)

Error

7.

What will be the output of the following Python program?

i = 0

while i < 5:

print(i)

i += 1

if i == 3:

break

else:

print(0)

a)

error

b)

0 1 2 0

c)

0 1 2

d)

none of the mentioned

8.

What will be the output of the following Python program?

def addItem(listParam):

listParam += [1]

mylist = [1, 2, 3, 4]

addItem(mylist)

print(len(mylist))

a)

5

b)

8

c)

2

d)

1

9.

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

d = {"john":40, "peter":45}

print(list(d.keys()))

a)

[“john”, “peter”]

b)

[“john”:40, “peter”:45]

c)

(“john”, “peter”)

d)

(“john”:40, “peter”:45)

10.

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

a = [0, 1, 2, 3]

for a[-1] in a:

print(a[-1])

a)

0 1 2 3

b)

0 1 2 2

c)

3 3 3 3

d)

error