0% found this document useful (0 votes)
530 views12 pages

List Based Questions

This document discusses list methods and functions in Python. It contains multiple choice questions about creating and manipulating lists. Some key list methods and functions covered include using indexes to access list elements, slicing lists, concatenating lists, replicating lists, checking membership in lists, inserting and removing elements, and built-in functions like len(), max(), min() and sorted().

Uploaded by

Ashna Gehlot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
530 views12 pages

List Based Questions

This document discusses list methods and functions in Python. It contains multiple choice questions about creating and manipulating lists. Some key list methods and functions covered include using indexes to access list elements, slicing lists, concatenating lists, replicating lists, checking membership in lists, inserting and removing elements, and built-in functions like len(), max(), min() and sorted().

Uploaded by

Ashna Gehlot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

bjective Type Questions

OTQs
Multiple Choice Questions
1 List can contain values of these types 6. Givern a list L=[10, 20, 30, 40, 50, 60, 701, what
(a) integers (b) floats would L[1: 4] return ?
c) lists (d) tuples (a) [10, 20, 30, 40] (b) [20, 30, 40, 50]
(e) all of these (c) [20, 30, 401 (d) [30, 40, 50]
2. Which of the following will create an empty 7.
. Given a list L=[10, 20, 30, 40, 50, 60, 701, what
list 3 would L[2: -2] return ?
(a) L [ ] (b) L = list(0) (a) [10, 20, 30, 40] (b) [20, 30, 40, 50]
(d) L = List(empty)
(c)L =list() () [20, 30, 40] (d) [30, 40, 50]
3. Which of the 8. Given a list L=[10, 20, 30, 40, 50, 60, 70],
following will return the last what
element of a list L with 5 elements ? would L4: -1] return ?
() L[5] (b) LI4] (a) [20, 30, 40] (b) [30, 40, 50]
(c)L-1 (d) L[6] (c)[40, 50, 60] (d) [50, 60, 70]
4.
If L =[1, 2] then L*2 will
yield 9.
9. Given a list L= [10, 20, 30, 40, 50, 60, 70], what
(a) [1, 2] 2 would L[-3 : 99] return ?
(b) [1, 2, 2]
() [1, 1, 2, 2] (d) [1, 2, 1, 2] (a) [20, 30, 40) (b) [30, 40, 501
t Ll =[1, 3, (c) [40, 50, 60] (d) [50, 60, 70]
5] and L2 =
[2, 4, 6] then LI+12
will yield 10. find the last element
To find element of
of list
list namely
10. namely 'smiles'
smiles
(a) [1, 2, 3, 4, 5, in Python, , will be used.
6] (b) [1, 3, 5, 2, 4, 6]
(c)13, 7, 11] (d) [1, 3, 5, (2, 4, 6]] (a) smiles[0] (b) smiles[-1]
(c) smiles[lpos] (d) smiles[:-1]
PRACTICts -X
11. Out of the following, what is correct syntax to 20. Which of the following will alwavs
copy one list into another? list ?
ways return a
(a) listA = listB[ ] (a) max( ) (b) min( )
(b) listA = listB[:] (c) listA = listB[ ( ) (c) sort() (d) sorted()
(d) listA = list(listB) 21. Which of the following can delete an
12. What is printed by the Python code ? from a list if the index of the element is nent
ven?
print(list(range (3))) (a) pop() (b) remove()
(b) [1, 2, 3] (c) del (d) all of these
(a) [0, 1, 2, 3]
(d) 0, 1, 2 22 Which of the following can delete
(c) [0, 1, 2 from a list, if its value is given ?
an
element
nent
13. Which of the following commands will create
a list? () pop() (b) remove()
(a) list1 list() (6) list1 [ (c) del (d) all of these
(c) list1 = list([1, 2, 3]) (d) all of these 23. Which of the following searches for an
element
in a list and returns its index ?
14. What is the output when we execute
list("hello") ? (a)search() (b) find()
(a) ('h', 'e', T, T, '01. (c) index( ) (d) Isearch()
(b) ['hello]. C)[lo']. 24 Which of the following can
copy a list to
(d) ['olleh1 another list?
15. What gets printed ? (a) list() (b) new( )
(d) = operator
names = [ 'Hasan', 'Balwant', 'sean', 'Dia'] (c) copy()
print(names[-1][-1]1) Fill in the Blanks
(a) H (b) n
1. Lists are data types and thus their
(c) Hasan (d) Dia (e) a
values can be changed.
16. What is the output of the following
l = [None] * 10
2. To create an empty list, function canbe
used.
print(len(1)) 3. The operator adds one list to the end of
another list.
(a) 10 (b) 0
() Syntax Error () None 4. The operator replicates a list.
17. Which of the following is a standard Python 5. To check if an element is in list,
operator is used.
library function and not an exclusively list
function ? 6. To delete a list slice from a list, is used.

7. The function is used to insert an


(a) append() (b) remove()
element at a designated position in a list.
pop() (d) len()
18. Which of the following can add only one value 8. The function is used to delete an

to a list ? element to remove an element from a

(a) add() (6) append() designated index in a list.


append a list of
(d) none of these 9 The function can
(c) extend()
elements to a list.
19 Which of the following can add a list of list and makes
elements to a list ? 10. The function sorts a

changes in the list.


a) add() (b) append()
11. The function sorts a list and returns
(c) extend() (d) none of these
another list.
Chopter 6 :LIST MANIPULATION

209
True/False Questions
6. The extend( ) adds à single element to a list.
The list() and
coPy() are the similar functions, 7. The
append() can add an element in the middle
The pop() and remove() are similar functions. of a list.
A = 1 and A = list() will produce the sar 8. The insert() can add an element in the middle
result. of a list.

Lists once created cannot be changed, 9. The del statement can only delete list slices
and not single elements from a list.
Sort a list, sort( ) and sorted( ), both can be
used.
10 The del statement can work similar to the popt
function.

NOTE Answers for Oras are given at the end of the book.

Solved Problems

1 How are lists different from the strings when both are sequences?
SoLUTION. The lists and strings are different in following ways
() The lists are mutable sequences while strings are immutable.
(i1) In consecutive locations, strings storé the individual characters while list stores the
references of its elements
elements
(in) Strings store of
single type elements all characters while lists can store

belonging to different types.

2 Assume the following list definition in Python.


letters ["a", "b", "o", "c", "p"
the following expressions if they are evaluated in the
What would be displayed in a Python shell for each of
an error then write error
given order ? 1f it would give
)>>>letters[-1] (i) » letters [len(letters) -2]
SoLUTION.
(i) "c"
() "p"
3.
3. Assume the same list: letters =
["a", "b", "o", "C', "pT
shell for each of the following expressions
What would be displayed in a Python
(ii) »» letters[2:-5:2]
(i) » letters[2: -5:-2]
( >>» letters[2:5:2]
SOLUTION.
(i) I'o']
) ['o', 'p']
What would be displayed in a Python shellfor each
Assume the same list: letters
= ["'a", "b", "o", "c", "p1.
44. are evaluated
in the given order?
of following expressions if they
the (i) >>» letters
()>>» letters + ["x"]

SoLUTION.
()["a", "b", "o", "c", "p",
"*"]
"p"]
(7) "b", "o", "c",
["a",
Assume the same list: letters = l"a", "b", "o", "C", "PI. What would be aispiayed in a Python shell for eaeu
ofthe following expressions if they are evaluated in the given order ? Ifit would give an error then writeou.
error
( » letters +2 (i) >» letters+[2] (ii) >>» letters += 2

()»» letters + [2] () » letters (vi) >» letters "xy

(vii) >»» letters+ "xy" (viin) >>» letters

SoLUTION.
() Error (TypeError: can only concatenate list (not "int") to list)
(i)"a', "b', 'o', 'c', 'p', 2]
(it) Error (TypeError: 'int' object is not iterable)
(iv) Nothing will be displayed and no error occurs.
(oa, 'b', 'o', 'c', 'p', 21
(vi) Error (TypeError. can only concatenate list (not "str") to list)
(vii) Nothing will be displayed and no error occurs.

(vii)['a', 'b', 'o', 'c', 'p', 2, 'x', 'y'1


6. What are nested lists ?
SoLUTION. When a list is contained in another list as a member-element, it is called nested list, e g,
a=[2,3, [4, 5]]
The above list a has three elements-an integer 2, an integer 3 and a list [4, 5], hence it is nested list.

7. What does each of the following expression evaluate to ?


Suppose that L is the list
These", "are", "a", I"few", "words"], "that", "we", "will", "use"].
(a) L[3:4]
L[3:4][0]
L[3:4][0][1]
L[3:4][0][1][2]
(b) "few" in L (C)"few"in L[3]
() [L[]]+L[3] ()L[4:] ) L[e::2]
SoLUTION. - it is a nested list

(a) L[3:4] =[[few, 'words]]


L[3:4][0] ['few, 'words']
L[3:4][0][1] = 'words'
L[3:4][0][1][2] = 'r

(b) False. The string "few" is part of a list which is an element of the list L, the literal string is
not an element of L.
(c) True. String "few" is part of list, which is at the index 3 of List L ie, L[3].
(d) [L[1]] = [ 'are ]
LI3] = [ 'fed, 'words']
[L[1]]+L[3] =['are', 'few, words]

() [ that', we', 'will, 'use']


( These', 'a, 'that', 'will]
LST MANIPULATIo
Chapter ó :

non-empty list of ints. Print the 211


smallest and largest integer in
SOLUTION length len(L) L. Write the code without
using a
loop
L.sort()
print ("smallest:", L[e])
print ("largest: ",
Write the most
L[length-1])
9. appropriate
list method to
perform the following tasks.
(a) Delete given element from the list.
a
(b) Delete 3rd element
Add an element in the end of the list. from the list.
(d) Add an element in the
(e) Add elements of a list in the end beginning of the list.
of a list
sOLUTION. (a) remove() (6) pop() (c)
append() (d) insert() ) extend()
What cwill be the output produced by the
1st1 [0, 1, [2]] following code ?
lst1[2][e] =3
print (lst1)
1st1[2].append (4)
print (lst1)
1st1[2] = 2

print (1st1)
SOLUTION. [O, 1, [3]]
[O, 1, [3, 4]1
[o, 1, 2]
11. Consider the below given two similar looking code fragments. Which of these will run properly and which one
will produce error? Exaplain.
(a) l s tlst = [1, 2] (b) » 1st = [1, 2]
l s t = l s t + "12" >»lst + "12"
SOLUTION. The code (a) will produce error because of its line 2: 1st = lst+ "12". Thisis because when
we use +operator with lists, we can only use lists as operands as only listscan be concatenated with
lists using +
The code (b) will not produce any error because lst += "12" does not expand to Ist = lst+ "12" as

on the right is an iterable (which is


works differently than + operator for lists. With +=, if, the operand
true in the code (b) as "12" is a string iterable),
then it will add each individual element of the iterable
to the list.
So after code (b) the Ist will contain [1, 2, 1, 21.
12. difference between append( ) and extend ) functions?
What is the
list of
element to a list while extend() can append a
SoLUTION. The append() can append only single
a

elements to a list, e.8


> val = [17, 24, 15, 30]
>> val.extend( [34, 27])
>> val.append(44)
>>> val
[17, 24, 15, 30, 34, 27,
44]
sort() andsorted)functions?
13. What is the difference between but, primary difference between
the
the list
sort the list elements,
SOLUTION. Both sort() and sorted() hunction will modify the list
it is working on.
the sort)
function is that
sort( ) function and the sorted()
212 INFORMATICS PRACTICES Y
The sorted( ) function will create a new list containing a sorted version of the list itit is
is oi.
sorted() function will not modify the list passed as a parameter. given. The
Thesort) works on a list whereas the sorted() can work on iterable seaun
different types of
Also, the sorted() function always returns a list whereas the sort( ) function modifiess the ences,
the list
list:
and has no return value. in-plac
14. Examine the following code :
numlist = eval(input ( "Enter list: "))
odds evens = 0

length = len (num list)


for pos in range(length):
i f numlist[pos] % 2 == 0
evens evens + 1

else
odds odds +1
i fodds > evens:
print ("Balanced oddity")
(a) What isthisprogram calculating? (b)Whatdoes the programfor thelist [1, 5,2,3, 6,6,9]?
(c) What does the program print for the list [2, 5, 2, 3, 6, 6, 9] ? How can we fix this ?
SOLUTION. (a) The given code is checking whether a list of numbers is 'mostly odd' - i.e, whether

there are more odd numbers than even numbers in the list. (b) Balanced oddity
() The code prints nothing. This is because there is only one print statement, the fix is :
i f odds > evens
print ("Balanced oddity")
else
print ("Unbalanced oddity")
15. Write a program to find the largest/smallest value of asset in a gioven list of assets of a company.
SoLUTION.
val = eval(input( "Enter list of assets: "))
print("The list is:", val)
mx = max(val) Enter 1ist of assets [23, 11, 56, 7, 12, 45]
The list is : [23, 11, 56, 7, 12, 45]
mn=min(val) Biggest ASset: 56
print("Biggest Asset: ", mx)
Smallest Asset :7
print("Smallest Asset: ", mn)

16. Write a program to input a list ofnumbers and swap elements at the even location with the elements at the odd
location.
SoLUTION.
val =
eval(input( "Enter a list: "))
Enter a 1ist [12, 23, 45, 16, 22, 34]
print("Original list is:", val) 34
original 1ist is [12, 23, 45, 16, 22,
S=len(val) 01
ifs%2 !=0: 2 3
S S-1 4 5
for i in range( 0, s, 2) : List after swapping: [23, 12, 16, 45, 34, 22)
print(i, i+1)
val[il, val[i+1] = val[i+1], val[ij
print("List after swapping: ", val)
LIST MANIPULATION
Chopte
6 213
ABC company's assets, iabilities and capital details are available in the form of three lists. Write a program to
oct if the accounting equation holds true for ABC
company or not.
SOLUTION.

assets =
eval(input(°Enter 1ist of assets:"))
1iab =
eval (input ("Enter list of liabilities: "))
cap eval(input("Enter list of capital:"))
sum(assets) Enter 1ist of assets: [5000, 5000]
if ==
sum (1iab)+ sum(cap) Enter 1ist of liabi lities: [1000, 1500, 500]
print("ACcounting eqn is balanced. ")
Enter list of capital: [5000, 2000]
else:
AcCounting eqn is balanced.
print ("Accounting eqn is not balanced.")
Given are the lists containing various sales and costs amounts for rwo companies ABC co. and XYZ co. Wrire
18.
a program to calculate the return-on-sales (ROS) for both the companies and display which company's
management sucessfully cuts costs while increasing revenue. Formula to calculate ROS isas given below
ROS=perating Profit
Net Sales
SOLUTION. abcSal= eval (input ("ABC co's sales list: "))
abcCost eval (input ("ABC co's cost list: "))
xyzSal- eval(input( "XZ co's sales list: "))
xyzCost eval(input("XYZ co's cost list: "))
abcOperProfit = sum(abcSal) -sum(abcCost)

abCROS abcOperProfit/sum (abcSal)


xyz0perProfit =sum(xyzSal) sum(xyzCost)
xyzROS = xyzOperProfit / sum(xyzSal)

print ("Return on Sales for ABC co. ", abcROS*100, "*")


Sales for XYZ co. : ", xyzROS*100, "*")
print("Return on
ifabcROS>xyzROS :
print("ABC co is better at cost-cutting while increasing revenue")
elifabcROS < xyzROS
while increasing revenue")
print ("XYZ co is better at cost-cutting
else:
at cutting costs.")
print ("both companies are doing equal
ABC co's sales list: [2500, 4500, 5500, 5000,
6000]
ABC co's cost list: [3500, 3000, 2000,
1000]
XY2 co's sales list: [6000, 7000,
4500, 5500]
XY2 co's cost list: [6000, 3000, 5000]
59.57446808510638 %
Return Sales for ABC c o . :
on
39.130434782608695 %
Return on sales for xYZ co. :
while increasing revenue
ABC co is better at cost-cutting

ofall the odd numbers in the list.


to calculate and display the
sum
9Givema list ofintegers, L, write a program

SOLUTION. # initially no sum


Sum BB #loop through list
:
for pos in range (len(L))
# this is an odd number
%2 1:
if L[pos] =

#so add it
sum sum + L[pos]
# the answer
print (sum )
214 INFORMATICS PRACTICES
20. Write a program to input a list of numbers and ask for a new element and its position. Then insert the e
the element
at given position.
Enter 1ist of
integers: [4, 6, 2,
SoLUTION. 81
original list: [4, 6, 2, 8]
lst =eval (input ("Enter list of integers: ")) Enter new element:5
print("original list:", lst) Insert at position? <4:3
el =
int(input("Enter new element: ")) List after insertion: [4, 6, 2, 5,81
ln len(lst)
pos int(input("Insert at position? <" + str(ln) + ": "))
1st.insert (pos, el1)
print("List after insertion: ", lst)
21. Write a program to find the second largest liability of a list of liabilities.
SOLUTION.
lst =
eval (input("Enter list of liabilities:"))
length len(lst)
biggest = secondbiggest = 1st[e] # though logically not faiir
for i in range(1, length):
if lst[i] > biggest:
secondbiggest = biggest
biggest = lst[i]

elif lst[i] > secondbiggest:


secondbiggest = lst[i]

print("Largest liability is:", biggest)


print("Second Largest liability: ", secondbiggest )
22.
22. Write a program to input a list Ist and two numbers M and N. Then create a
listfrom those lst elements twnicu
are divisible by both M and N.
SOLUTION.
lst =eval(input ("Enter a list:"))
lst2 []
M, N eval (input ("Enter two numbers as M, N :"))
for num in 1st:
if( num %M == 0 and num %N == 0) Enter a list: [6, 8, 11, 6, 12, 7, o
lst2.append(num) Enter two numbers as
M, N :6,2
print("New created list is :", lst2) New created 1ist is: [6, 6, 12]
Assignmenfs
Solutions for
Selected Questions

TypeA:Short Answer Questions/Conceptual Questions

Discuss the utility and significance of Lists, briefly.


What do you understand by Scan
mutability? What does "in place" memory updation OR Code
mean ?

. Start withthe list [8, 9, 10]. Do the


following using list functions
() Set the second entry (index 1) to 17 (6) Add 4, 5 and6 to the end of the list
Remove the first entry from the list Sort the list
(d)
(e) Double the list
( Insert 25 at index 3
4. If a is [1, 2, 3]
(a) what is the difference (if any) between a
*
3 and [a, a, a] ?
(b) is a * 3 equivalent to a + a+ a?

(c) what is the meaning of a[1:1] =9?


(d) what's the difference between a[1:2] 4 and a[1:1] =4 ?
5 What's a [1 1] if a is a list of at least two elements ? And what if the list is shorter ?
218 INFORMATICS PRACTICES X
6. How are the statements lst Ist+3 and lst + [3] different, where lst is a list ? Explain.
7. How are the statements lst + "xy" and Ist lst+ "xy" different, where lst is a list ? Explain
8. What's the purpose of the del operator and pop method ? Try deleting a slice.
9 What does each of the following expressions evaluate to ? Suppose that L is the list

These", ["are", "a", "few", "words"], "that", "we", "will", "use'"


(@) L[1][e: :2] (b) "a" in L[1][e] (c) L[:1]+L[1]
()L[2::2] () L[2][2] in L[1]
10. What are list slices ? What for can you use them ?
11. Does the slice operator always produce a new list ?
12. Compare lists with strings. How are they similar and how are they different?
13. What do you understand by true copy of a list ? How is it different from shallow copy ?
14. An index out of bounds given with a list name causes error, but not with list slices. Why ?
15. What is the difference between appending a list and extending a list ?

16. Do functions max( ), min( ), sum( ) work with all types of lists?
17. What is the difference between sort( ) and sorted() ?

Type B: Application Based Questions


1. What is the difference between following two expressions, if Ist is given as [1, 3, 5]
() 1 s t 3 and 1st = 3 (ii) lst + 3 and lst += [3]

Given two lists


L1 = ["this", 'is', 'a', 'List'], L2 =["this", [ "is", "anothe "], "List"]

Which of the following expressions will cause an error and why ?

(a)L1==L2 (b) L1.upper() ()L1[3].upper()


(d)L2.upper() e)L2[1].upper() ( L2[1][1].upper()
3. From the previous question, give output of expressions that do not result in error.
4 Given a list L1 = [3, 4.5, 12, 25.7, [2, 1, 0, 5], 88]

(a) Which list slice will return [12, 25.7, [2, 1, 0, 5]] ?
(b) Which expression will return [2, 1, 0, 5] ?
)Which list slice will return [12, 1, 0, 5|1 ?
(d) Which list slice will return [4.5, 25.7, 88]?
Given a list L1 [3, 4.5, 12, 25.7, 12, 1, 0, 5, 881, which function can change the list to
(a) 13, 4.5, 12, 25.7, 88] 6)13, 4.5, 12, 25.7] )2,1, 0, 5], 88]
6. What will the following code result in ?
L1 [1, 3, 5, 7, 9]
print (L1 == L1.reverse())
print (L1)
7. Predict the output:
my_1ist=['p', 'r'» 'o', 'b', '1', 'e', 'm']| 8. Predict the output:
my_1ist[2:3] = []
Listi [13, 18, 11, 16, 13, 18, 13B
print(mylist) print(Lista.index(18))
my_1ist(2:5] - []
print(List1.count(18))
print (my_list) List1.append(List1.count(13))
print(Listi)
Chapter 6 : LIST MANIPULATION

9. Predict the output: 219


odd [1,3,5]
print( (Odd +[2, 4, 6])[4] )
print( (Odd [12, 14,
10. Predict the output: 16])[4] (Odd +[2, -

4, 6])[4]
a, b, c [1,2]. [1, 2], [1,
print(a == b) 2]
print (a is b)
11, Predict the output of
following two parts. Are the outputs same? Are the
(@) L1, L2 =[2, 4], [2, 4] outputs different? Why?
L3 = L2 (b) L1, L2 - [2, 4), [2, 4]
L2[1] 5 L3 list(L2)
print(L3) L2[1] 5
print(L3)
12, Find the errors : 1. L1 =
[1, 11, 21, 31]
2. L2 L1+2
3. L3 L1 *2
4. Idx =

L1.index(45)
13. Find the errors
()L1 [1, 11, 21, 31] (b) L1 [1, 11, 21, 31]
An L1.remove(41) An L1.remove(31)
print(An+2)
14. Find the errors
(a) L1 [3, 4, 5] (b) L1 [3, 3, 8, 1, 3, 0, 1', 'e', '2', 'e',
=
*, 'e, 'r]
L2 L13 print( L1[: : 1])
print (L1 '3.0) print( L1 [-1: -2:-3]
print(L2) print( L1 [1:-2:-3: 4])
15. What will be the output of following code ?
X = [3, '2, '5]

y =''

for a in x :
y =y + x [-1]
Xx [: len(x) -1]
print (y)
print (x)
print (type(x), type(y))
integer between 0 and 100, inclusive, named nums1 using
l6, Complete the code to create a list of every
order.
Python, sorted in increasing command that will append the last
non-empty lists. Write a Python
L e t nums2 and nums3 be two
of nums2.
element of nums3 to the end statements.
result of the following
and predict the
o, Consider the following code
'nom']
['om', 'nom',
bieber
counts [1, 2, 3]
nums = counts

ums.append (4) counts is add([1, 2, 13, 4)


(i)
() counts is nums
220
INFORMATICS PRACTICESY - XI

19. What is the output of the following code ?


numbers list( range(0, 51, 4))
results = []

for number in numbers:


if not number % 3:
results.append (number)
print(results)
20. Following code prints the given list in ascending order. Modify the code so that the elements are printod
in the reverse order of the result produced by the given code.
numbers list(range(0, 51, 4)
i = 6

for i in range(len (numbers)) "


print(numbers [i] , end =

it3
#gives output as : 0 12 24 36 48

Type C Programming Practice/Knowledge based Questions


1. Write a
program to increment the elements of a list with a number.
2. Write a
program that reverses a list of integers (in place).
3. Write a program that inputs two lists and creates a third, that contains all elements of the first followed
by all elements of the second.
4 Ask the user to enter a list containing numbers between 1 and 12. Then replace all of the entries in the
list that are greater than 10 with 10.
5. Ask the user to enter a list of strings. Create a new list that consists of those strings with their first
characters removed.
6. Write a program to input if a number is
present in the list or not. If the number is present, print the
position of the number. Print an appropriate message if the number is not present in the list.
7. Create the following lists using a for loop:
(a) A list consisting of the integers 0 through 49.
(b) A list containing the squares of the integers 1 through 50.
() The list ['a', bb', ccc, dddd', .. .] that ends with 26 copies of the letter z.
8. Write a program that takes any two lists L and M of the same size and
adds their elements
form a new list N whose elements are sums of the corresponding elements in L and M. For together
to
instance, if
L=[3,1, 4] and M =
[1, 5,9], then N should equal [4,6,13].
9. Write a
program rotates the
elements of a list so that the element at the first index moves to the second
index, the element in the second index moves to the third index, etc., and the element in the last index
moves to the first index.
10. Write a program to read two lists num and denum which contain the numerators and denominators of
same fractions at the respective indexes. Then
display the smallest fraction along with its index.
11. Write a program to display the maximum and minimum values from the specified range of indexes of a ist.
12. Write program to move all duplicate values in a list to the end of the list.
a

13. Write a program to


compare two equal sized lists and print the first index where they differ.
14. From a balance sheet of a
company (choose any from your Accountancy book) and create lists for
liabilities and equity. Then write a program to check if accounting equation is balanced or not.asst1e
program should also calculate Return on Total Assets as

EBIT(Earning Before Interest and laxes) and Total Liabilities


Total Net Assets Debt/Equity ratio as
Assets -Liabilities

You might also like