Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Test 4A

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following would give an error?

a)

list1=[]

b)

list1=[]*3

c)

list1=[2,8,7]

d)

None of the above

2.

Which of the following is True regarding lists in Python?

a)

Lists are immutable.

b)

Size of the lists must be specified before its initialization

c)

Elements of lists are stored in contagious memory location.

d)

size(list1) command is used to find the size of lists.

3.

What will be the output of below Python code?

list1=[8,0,9,5]

print(list1[::-1])

a)

[5,9,0,8]

b)

[8,0,9]

c)

[8,0,9,5]

d)

[0,9,5]

4.

Which of the following will give output as [23,2,9,75] ?

If list1=[6,23,3,2,0,9,8,75]

a)

print(list1[1:7:2])

b)

print(list1[0:7:2])

c)

print(list1[1:8:2])

d)

print(list1[0:8:2])

5.

The marks of a student on 6 subjects are stored in a list, list1=[80,66,94,87,99,95]. How can the student’s average mark be calculated?

a)

print(avg(list1))

b)

print(sum(list1)/len(list1))

c)

print(sum(list1)/sizeof(list1))

d)

print(total(list1)/len(list1))

6.

 What will be the output of following Python code?

list1=["Python","Java","c","C","C++"]

print(min(list1))

a)

c

b)

C++

c)

C

d)

min function cannot be used on string elements

7.

The elements of a list are arranged in descending order. Which of the following two will give same outputs?

  i. print(list_name.sort())  

 ii. print(max(list_name))  

 iii. print(list_name.reverse())  

 iv. print(list_name[-1])

a)

i, ii

b)

i, iii

c)

ii, iii

d)

iii, iv

8.

What will be the result after the execution of above Python code?

list1=[3,2,5,7,3,6]

list1.pop(3)

print(list1)

a)

[3,2,5,3,6]

b)

[2,5,7,3,6]

c)

[2,5,7,6]

d)

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

9.

What will be the output of below Python code?

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

list1.remove(2)

print(sum(list1))

a)

18

b)

19

c)

21

d)

22

10.

What will be the output of below Python code?

list1=["tom","mary","simon"]

list1.insert(5,8)

print(list1)

a)

["tom", "mary", "simon", 5]

b)

["tom", "mary", "simon", 8]

c)

[8, "tom", "mary", "simon"]

d)

Error