wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CAI625 Practice Quiz

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?

a)

[3, 5, 20, 5, 25, 1, 3]

b)

[3, 4, 5, 20, 5, 25, 1, 3]

c)

[1, 3, 3, 4, 5, 5, 20, 25]

d)

[1, 3, 4, 5, 20, 5, 25]

2.

What data type is the object below ?

L = [1, 23, 4, 1]

a)

List

b)

Array

c)

Dictionary

d)

Node

3.

What is the output of the following command?

print ("Hello World"[:-1])

a)

Hello World

b)

Hello Worl

c)

d

d)

Error

4.

What is the output of the following program :

def myfunc(a):

a = a + 2

a = a * 2

return a


print myfunc(2)

a)

8

b)

16

c)

Indentation Error

d)

Runtime Error

5.

Suppose list1 is [2, 33, 222, 14, 25], which of the following will print 25?

a)

print(list1[25])

b)

print(list1[5])

c)

print(list1[:-1])

d)

print(list1[-1])

6.

What will be the output of the following Python code?

list1 = [1,2,3,4,5]

list2 = [6,7]

list1.extend(list2)

print(list2)

a)

[6, 7]

b)

[1,2,3,4,5]

c)

[1, 2, 3, 4, 5, 6, 7]

d)

Error

7.

What will be the output of the following Python code?

list1 = [1,2,3,4,5]

list2 = [6,7]

list1.extend(list2)

print(list1)

a)

[6, 7]

b)

[1,2,3,4,5]

c)

[1, 2, 3, 4, 5, 6, 7]

d)

Error

8.

Which of the following statements create a dictionary?

a)

d = {}

b)

d = {“Ali”:40, “Salem”:45}

c)

d = {40:”Ali”, 45:”Salem”}

d)

All of the mentioned

9.

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

d = {"Tareq":40, "Salem":45}

print(d["Tareq"])

a)

40

b)

45

c)

2

d)

Salem

10.

If a={5,6,7}, what does a become when a.add(5) is executed?

a)

{5,5,6,7}

b)

a={5,6,7}

c)

5

d)

Error as 5 already exists in the set