WorksheetsPython Test 4A
Total questions: 10
Worksheet time: 5mins
Which of the following would give an error?
list1=[]
list1=[]*3
list1=[2,8,7]
None of the above
Which of the following is True regarding lists in Python?
Lists are immutable.
Size of the lists must be specified before its initialization
Elements of lists are stored in contagious memory location.
size(list1) command is used to find the size of lists.
What will be the output of below Python code?
list1=[8,0,9,5]
print(list1[::-1])
[5,9,0,8]
[8,0,9]
[8,0,9,5]
[0,9,5]
Which of the following will give output as [23,2,9,75] ?
If list1=[6,23,3,2,0,9,8,75]
print(list1[1:7:2])
print(list1[0:7:2])
print(list1[1:8:2])
print(list1[0:8:2])
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?
print(avg(list1))
print(sum(list1)/len(list1))
print(sum(list1)/sizeof(list1))
print(total(list1)/len(list1))
What will be the output of following Python code?
list1=["Python","Java","c","C","C++"]
print(min(list1))
c
C++
C
min function cannot be used on string elements
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])
i, ii
i, iii
ii, iii
iii, iv
What will be the result after the execution of above Python code?
list1=[3,2,5,7,3,6]
list1.pop(3)
print(list1)
[3,2,5,3,6]
[2,5,7,3,6]
[2,5,7,6]
[3,2,5,7,3,6]
What will be the output of below Python code?
list1=[1,3,5,2,4,6,2]
list1.remove(2)
print(sum(list1))
18
19
21
22
What will be the output of below Python code?
list1=["tom","mary","simon"]
list1.insert(5,8)
print(list1)
["tom", "mary", "simon", 5]
["tom", "mary", "simon", 8]
[8, "tom", "mary", "simon"]
Error
