wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Tech Python

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

Which of the following is NOT a programming paradigm?

a)

Object Oriented

b)

Functional

c)

Procedural

d)

Relational

2.

Which of the following is immutable?(more than 1 correct answer)

a)

Tuple

b)

String

c)

List

d)

Int

3.

What is the OUTPUT?

print([] is [])

a)

True

b)

False

c)

Error

d)

None

4.

Which of the following is not a valid Python data type?

a)

list

b)

tuple

c)

array

d)

set

5.

What is the output?

print(len([[]]))

a)

0

b)

1

c)

2

d)

Error

6.

What is the OUTPUT?

print(type({1,2,3}))

a)

list

b)

tuple

c)

set

d)

dict

7.

What is the OUTPUT?

print(0.1 + 0.2 == 0.3)

a)

True

b)

False

c)

Error

d)

None

8.

What does pass do in Python?

a)

Stops loop

b)

Skips iteration

c)

Does nothing

d)

Raises error

9.

x = 10

def f(y=x):

return y

x = 20

print(f())

What is the OUTPUT?

(a)  

10.

a=257

b=257

print(a is b)

What is the OUTPUT?

a)

True

b)

False

c)

Error

d)

None

11.

def pack(item, sack=[]):

sack += [item]

return sack

print(pack("toy"))

print(pack("book"))

What is the OUTPUT?

a)

["toy"], ["toy", "book"]

b)

["toy"], ["book"]

c)

Error

d)

Empty list

12.

kids = {True: "Nice", 1: "Naughty", 1.0: "??? "}

print(len(kids))

What is the OUTPUT?

(a)  

13.

print([] == False)

What is the OUTPUT?

a)

True

b)

False

c)

Error

d)

None

14.

a = [1, 2, 3]

b = a

a += [4, 5]

print(b)

What is the OUTPUT?

a)

[1,2,3]

b)

Error

c)

[1,2,3,4,5]

d)

[1,2]

15.

print([i for i in range(3)] is [i for i in range(3)])

What is the OUTPUT?

(a)  

16.

What is the OUTPUT?

print(type(type(int)))

a)

int

b)

class

c)

type

d)

error

17.

def test():

try:

return 1

except:

return 2

finally:

return 3

What is the OUTPUT?

a)

1 2 3

b)

1 2

3

c)

1 2

d)

3

18.

What is the OUTPUT?

print(True + True)

a)

True

b)

1

c)

2

d)

0

e)

Error

19.

x = [[0]] * 3

x[0][0] = 1

print(x)

What is the OUTPUT?

a)

[[1],[3],[3]]

b)

[1],[3],[3]

c)

[[3],[3],[3]]

d)

[[1],[1],[1]]

e)

[1],[1],[1]

20.

x = 10

x = "Python"

print(x)

What is the OUTPUT?

a)

10

b)

Python

c)

Error

d)

None

21.

def f(x=[]):

x.append(1)

print(x)

f()

f()

What is the OUTPUT?

a)

[1] [1]

b)

[1] [1,1]

c)

[1] [11]

d)

[11]

e)

[1], [11]

22.

What is the output?

x = 10

def f():

print(x)

x = 5

f()

a)

10

b)

5

c)

UnboundLocalError

d)

NULL

23.

Which bug exists in this code?

def add(item, lst=[]):

lst.append(item)

return lst

a)

Syntax error

b)

Logical error due to mutable default argument

c)

Runtime error

d)

No error

24.

What is the OUTPUT?

print(False == False in [False])

a)

True

b)

False

c)

Error

d)

None

25.

What is the output?

x = 1

def f():

return x

def g():

x = 2

return f()

print(g())

(a)  

26.

What is the output?

x = [[1]] * 3

x[0][0] = 9

print(x)

a)

[9],[1],[1]

b)

[9],[9],[9]

c)

[[9],[1],[1]]

d)

[[9],[9],[9]]

27.

What is the output?

print([] or {} and ())

a)

[]

b)

{} or ()

c)

()

d)

[] or ()

e)

Error

28.

Which operator is used for floor division?

(a)  

29.

What is the output?

a = [1, 2, 3]

b = a

b.append(4)

print(a)

a)

[1, 2, 3]

b)

[1, 2, 3, 4]

c)

Error

d)

[4]

30.

What will be printed?

x = [i*i for i in range(3)]

print(x)

a)

[1, 4, 9]

b)

[0, 1, 4]

c)

[0, 1, 2]

d)

Error