Professional Documents
Culture Documents
PYTHON PROGRAMMING
a. List is value mutable b. List can store heterogeneous items c. List is size
immutable d. List is ordered collection of items
ii. We can use both index and negative index of list items to access it.
a. i true, ii false b. i false, ii true c. both are true d. both are false
3.To find the total no of elements in list we can use ________ method ( )
L =[23,34,45,12,32]
Print(L[-3])
a. 45 b. 34 c. Error d. 12
L = [‘s’,’a’,’n’,’j’]
print(L[4])
L = [3,5,2]
print(L*2)
8.____ method adds a new item/list as a single element at the end of list ( )
12._______ method adds each element of list passed as argument at the end of
the given list. ( )
13.Select the correct statement to display the last element of list ‘L’?
( )
14.Select the correct statement to display the first element of list ‘L’?
( )
15.Which of the following is correct code to display largest element of list ‘L’?
( )
16.Which of the following is correct code to display second largest element of list
‘L’? ( )
print(L[-1]) print(L[1])
17.Look at the following code and state which type of list operation it carries out?
( )
list = [‘t’,’e’,’c’,’h’,’t’,’i’,’p’,’n’,’o’,’n’,’w’]
for x in list:
print(x)
18.Look at the following code and state which type of list operation is being
carried out? ( )
list = [‘t’,’e’,’c’,’h’,’t’,’i’,’p’,’n’,’o’,’n’,’w’]
L = list*3
print(L)
19.Look at the following code and state which type of list operation is being
carried out? ( )
list = [‘t’,’e’,’c’,’h’,’t’,’i’,’p’,’n’,’o’,’n’,’w’]
Print(L[2:8:2])
L = [4,5,8,2,1,9]
L.pop(4)
print(L)
L = [4,5,8,2,1,9]
L.remove(4)
print(L)
a. [4,5,8,1,9] b. [4,5,8,2] c. [4,5,8,2,9] d. [5,8,2,1,9]
List1 = [2,3,4,5]
List2 = [6,7,8]
List1.extend(List2)
Print(List1)
List1 = [2,3,4,5]
List2 = [6,7,8]
List1.append(List2)
Print(List1)
list1 = [3,4,6,4,7, 8]
list1.remove(4)
print(list1)
list1 = [2,5,6,7]
Now he wants to add 12 at the end of list1. Help him to write correct code for it
L = [3,6,87,12,6]
L.remove()
techtipnow want to find the average sale of week. Help him to write code for so.
list1 = [‘mango’,’orange’,’grapes’,’banana’,’guava’]
a1 = [2,3]
a2 = [3,5,7]
a2.append(a1)
print(a1 in a2)
exp = [2,3,4,5,6,4,8,2,4,10]
exp.remove(4)
c = exp.count(4)
print(c)
a. error b. 1 c. 2 d. 9
a. not b.is c. in d. or
print(sum(L1))
will produce
37.Surekha stored attendance of her class for this week in list ‘atd’ as given
below: ( )
atd = [32,37,23,28,30,40,31]
principal ask her to fi nd the median of given nos. what code she write in python to get
this?
a. print(sum(atd)/len(atd)) b. print(sum(atd)/count(atd))
c. std.sort() d. std.sort()
print(atd[len(atd)//2]) print(atd[(len(atd)//2)+1]
38.Jayesh created a list ‘L1’ with duplicate items. Ishaan suggested him to modify
this list so it does notcontains any duplicate element i.e. all elements occurring
multiple times in the list should appear onlyonce. Helm him to do so. ( )
L = [1,2,3]
print(L + L*L)
a. [1,2,3,1,4,9] b. [1,6,12] c. [1,2,3,1,2,3,1,2,3] d. Error
print(len(m))
a. Error b. 17 c. 8 d. 7
K = [3,4,6,7,2,1,8,9,4,6]
we can write
L=[4,5,6,7,2,3,1,5,3,6]
ii. We cannot use slices to modify one or more list items with one or more other items.
K = [3,4,6,7,2,1,8,9,4,6] print(K[3:-3])
He asked his student to write code to delete last element of list L1. Help them to select
correct code.
50.Continue to the previous question 49, Sir wanted to add a new number 66
before 19 in list L1. He askedRaheem to identify the position of 19 and insert that.
What code Raheem should tell him? ( )