You are on page 1of 8

Name: ____________________ Roll No.

:___________________ Year/Sec:_________ SET-1

GEETHANJALI COLLEGE OF ENGINEERING AND TECHNOLOGY


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

PYTHON PROGRAMMING

1..Which of the following is NOT true about List? ( )

a. List is value mutable b. List can store heterogeneous items c. List is size
immutable d. List is ordered collection of items

2.Select correct statement ( )

i. Duplicate items are not allowed to store in List

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 ( )

a. length() b. len() c. count() d. find()

4.to remove an item from list we can use ( )

a. pop() b. remove() c. del() d. both a and b e. all of the above

5.What will be output of given code? ( )

L =[23,34,45,12,32]

Print(L[-3])

a. 45 b. 34 c. Error d. 12

6.Predict the output of ( )

L = [‘s’,’a’,’n’,’j’]

print(L[4])

a. s b. j c. index error d. sanj

7.display the output of given code: ( )

L = [3,5,2]
print(L*2)

a. [ 6, 10, 4] b. [3, 5, 2, 3, 5, 2] c. [9, 25, 4] d. None

8.____ method adds a new item/list as a single element at the end of list ( )

a. extend() b. append() c. insert() d. list()

9._________ method add an element at a particular index in the list. ( )

a. extend() b. append() c. insert() d. list()

10.to delete an element using its index no we can use ( )

a. pop() b. remove() c. delete() d. find()

11.to delete an element using its value _________ can be used. ( )

a. pop() b. remove() c. del() d. list()

12._______ method adds each element of list passed as argument at the end of
the given list. ( )

a. extend( ) b. append() c. insert() d. list()

13.Select the correct statement to display the last element of list ‘L’?
( )

a. L[-1] b. L[len(L)-1] c. L[len(L)] d. Both a and b e. Both a and c

14.Select the correct statement to display the first element of list ‘L’?
( )

a. L[0] b. L[1] c. L[-len(L)] d. L[-len(L)-1]

15.Which of the following is correct code to display largest element of list ‘L’?
( )

a. L.sort() print(L[-1]) b. L.sort(reverse = True) print(L[0]) c. max(L) d. All of the


above

16.Which of the following is correct code to display second largest element of list
‘L’? ( )

a. L.sort() b. L.sort(reverse = True) c. print(sorted(L)[-1]) d. All of the


above

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)

a. Repeating List b. Traversing List c. Slicing list d. Joining list

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)

a. Repeating List b. Traversing List c. Slicing list d. Joining list

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])

a. Repeating List b.Traversing List c. Slicing list d. Joining list

20.Predict the output: ( )

L = [4,5,8,2,1,9]

L.pop(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]

21.Predict the output: ( )

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]

22.Find the output of given code? ( )

List1 = [2,3,4,5]

List2 = [6,7,8]

List1.extend(List2)

Print(List1)

a. [2,3,4,5,[6,7,8]] b. [[2,3,4,5],6,7,8] c. [2,3,4,5,6,7,8] d. [[2,3,4,5],[6,7,8]]

23.Find the output of given code? ( )

List1 = [2,3,4,5]

List2 = [6,7,8]

List1.append(List2)

Print(List1)

a. [2,3,4,5,[6,7,8]] b. [[2,3,4,5],6,7,8] c. [2,3,4,5,6,7,8] d. [[2,3,4,5],[6,7,8]]

24.What will be output of following code? ( )

list1 = [3,4,6,4,7, 8]

list1.remove(4)

print(list1)

a. [3,4,6,4,8] b. [3,6,4,7,8] c. [3,6,7,8] d. 3,4,6,7,8]

25.Raju has created following list: ( )

list1 = [2,5,6,7]

Now he wants to add 12 at the end of list1. Help him to write correct code for it

a. list1.insert(len(list1), 12) b. list1.append(12) c. list1.extend([12]) d. All are


correct

26. Which type of error following code will produce? ( )

L = [3,6,87,12,6]
L.remove()

a. Index error b. Value error c. Logical error d. Runtime error

27. If no argument is passed to pop(), it removes ( )

a. First element of list b. Last element of list c. Produce error d. No element is


removed

28. To sort a list ‘exp’ in decreasing order we can write ( )

a. exp.sort() b. exp.sort(reverse = True) c. exp.sort(reverse = False) d.


exp.sort(asc = True)

29. The sale of techtipnow for this week is stored in a list1 as


[25,45,23,52,61,40,36]. Manager of ( )

techtipnow want to find the average sale of week. Help him to write code for so.

a. sum(list1)/count(list1) b. avg(list1) c. sum(list1)/len(list1) d.


total(list1)/count(list1)

30. predict the output for following code: ( )

list1 = [‘mango’,’orange’,’grapes’,’banana’,’guava’]

a. banana b. grapes c. guava d. orange

31.select the command to insert a number 12 at 4 ( )

position of list named list1.

a. list1.insert(4,12) b. list1.insert(3,12) c. list1.insert(12,4) d. list1.insert(12,3)

32.what will be correct output when given code will be executed? ( )

a1 = [2,3]

a2 = [3,5,7]

a2.append(a1)

print(a1 in a2)

a. True b. False c. Error d. [2,3]

33.Find the output: ( )

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

34.To check whether an item is present in list or not, we can use ( )

a. not b.is c. in d. or

35.to get the index value of an item of list1, we can write ( )

a. list1.index(value) b. index(list1, value) c. index(value, list1) d. list1[value].index

36.for a given list L1 as [[2,3,[4,5],6,7]], if you execute following command ( )

print(sum(L1))

will produce

a. 27 b.No output c. error d. 0

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. ( )

a. R=[]for i in range(L1):if i not in R:R.append(i) b. R = list(set(L1)) c. Both d. None

39.Predict the output of given code: ( )

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

40.Rajesh wrote following code to fi nd the length of a list : ( )

m = [12, ‘techtipnow’,[10,11],12.08,’x’,True, 30]

print(len(m))

what output you can predict for this code?

a. Error b. 17 c. 8 d. 7

41.Creating new list by extracting items from existing list is called ( )

a. Traversing b. Copying c. Slicing d. Extending

42.To display all items of list1 in reverse order we can write ( )

a. List[::-1] b. List1.reverse() c. Both d. None

43.To display fi rst 3 items for given list ( )

K = [3,4,6,7,2,1,8,9,4,6]

we can write

a. K[:3] b. K[:-7] c. K[-10:3] d. All of the above

44.For given list ( )

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

if we try to slice L[6:13], than what will be the output?

a. [1, 5, 3, 6] b. [1, 5, 3, 6,0,0,0] c. Index Error d. [ ] (No Output)

45.Suppose list1 is [‘a’,’e’,’i’,’o’,’u’], than what will be list1[:-1]? ( )

a. [‘a’,’e’,’i’,’o’,’u’] b. [‘a’,’e’,’i’,’o’] c. [‘u’,’o’,’i’,’e’,’a’] d. [ ]

46.Select the correct statement:


( )

i. Slicing cannot be done on a variable

ii. We cannot use slices to modify one or more list items with one or more other items.

a. i true, ii falsem b. I false, ii true c. Both true d. Both false


47.Predict the output of given code ( )

K = [3,4,6,7,2,1,8,9,4,6] print(K[3:-3])

a. [7,2,1,8] b. [7,2,1,8,9] c. [8,1,2,7] d. [7]

48.For a given list1[3,4,6,7,2,1,8,9,4,6], what code we can write to display its


alternate items frombeginning? ( )

a. List1[:2]Discover employer of record services Solution. Find Related Results Now


Open

b. List1[::2] c. List1[0:len(List1):2] d. All of the above

49.Rajneesh Sir has made following list:


( )

L1 = [74, 33, 22, 19, 41, 65]

He asked his student to write code to delete last element of list L1. Help them to select
correct code.

a. L1.pop(len(L1)-1) b. L1.pop(-1) c. del L1[-1] d. All are correct

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? ( )

a. L1.append(L1.index(19), 66) b. L1.insert(L1.index(19), 66) c. L1.append(66,


L1.index(19)) d. L1.insert(66, L1.index(19))

You might also like