wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Coding Contest

Total questions: 20

Worksheet time: 15mins

Name
Class
Date
1.

Who developed Python Programming Language?

a)
Elon Musk
b)
Mark Zuckerberg
c)
Bill Gates
d)
Guido van Rossum
2.

What will be the output of the following Python function?

len(["hello",2, 4, 6])

a)
5
b)
3
c)

Error

d)
4
3.

What will be the output of the following Python code snippet if x=1?

x<<2

a)
2
b)
4
c)
6
d)
8
4.

What will be the output of the following Python statement?

>>>"a"+"bc"

a)

bc

b)

abc

c)

a

d)

bca

5.

Which one of the following is not a keyword in Python language?

a)

pass

b)

eval

c)

assert

d)

nonlocal

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)
224
b)

12

c)
None
d)

tester

7.

What will be the output of the following Python program?

z=set('abc')

z.add('san')

z.update(set(['p', 'q']))

z

a)

{‘a’, ‘c’, ‘c’, ‘p’, ‘q’, ‘s’, ‘a’, ‘n’}

b)

{‘abc’, ‘p’, ‘q’, ‘san’}

c)

{‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}

d)

{‘a’, ‘b’, ‘c’, [‘p’, ‘q’], ‘san}

8.

Which of the following Python statements will result in the output: 6?

A = [[1, 2, 3],

[4, 5, 6],

[7, 8, 9]]

a)
A[0][2]
b)
A[1][2]
c)
A[1][3]
d)
A[2][1]
9.

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)

None

b)

0

1

2

0

c)

Error

d)
0 1 2
10.

Which of the following is a Python tuple?

a)

{1, 2, 3}

b)

{}

c)

[1, 2, 3]

d)

(1, 2, 3)

11.

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

z=set('abc$de')

'a' in z

a)
error
b)

True

c)

False

d)
null
12.

What will be the output of the following Python expression?

round(4.576)

a)
5
b)

4.6

c)

4.5

d)
4
13.

What is output of print(math.pow(3, 2))?

a)

9.0

b)
9
c)

None

d)

None of the mentioned

14.

What will be the output of the following Python code?

x = [[0], [1]]

print((' '.join(list(map(str, x))),))

a)
(['0', '1'],)
b)
(['0'] ['1'],)
c)

01

d)
(['0'] , ['1'],)
15.

Which of the following will run without errors?

a)

round(45.8)

b)

round(6352.898,2,5)

c)

round()

d)

round(7463.123,2,1)

16.

What is the return type of function id?

a)

int

b)

float

c)

bool

d)

dict

17.

What error occurs when you execute the following Python code snippet?

apple = mango

a)

ValueError

b)

NameError

c)

SyntaxError

d)

TypeError

18.

What is the average value of the following Python code snippet?

>>>grade1 = 80

>>>grade2 = 90

>>>average = (grade1 + grade2) / 2

a)
70
b)
85
c)
95
d)
100
19.

Which is the correct operator for power(xy)?

a)

x^y

b)

x**y

c)

x^^y

d)

None of the mentioned

20.

What is the answer to this expression, 22 % 3 is?

a)

7

b)

1

c)

0

d)

5