Python Programming 2 Create a list L1 consisting of the inte

Python Programming

2) Create a list (L1) consisting of the integers: 11,5,7,8,10, and 11. Using List functions and methods do the following:

i. Find the sum of the integers in L1

ii. Find the maximum value in L1

iii. Update L1 by adding the integer 50 to the end of L1

iv. Update L1 by adding the elements in the list [45,34,56,11]

v. After steps (iii) and (iv), find the number of elements in L1

vi. Find the index of the value 8 in L1

vii. Remove the last element in L1

viii. Remove the first element in L1

ix. Reverse the first element from L1

x. Count the number of occurrences of the integer 11 in L1

Solution

L1 = [11,5,7,8,10,11];
print \"ii)Maximum value of list\",max(L1);#maximum value in the list
print \"i)Sum\",sum(L1);#sum of all the elements in the list
L1.append(50);#appending 50 value in the list
print L1;
print \"Length\",len(L1);#printing length of list
L1.append(45);
L1.append(34);
L1.append(56);
L1.append(11);
print L1;
print \"Length\",len(L1);
print \"Index of value 8 is: \",L1[8];#printing the value of list at index
del(L1[-1]);#deleting last element
print L1;
del(L1[0]);#deleting first element
print L1;
L1.reverse();#reversing the list
print L1;
print L1.count(11);#printing no. of occurances of particular number

Python Programming 2) Create a list (L1) consisting of the integers: 11,5,7,8,10, and 11. Using List functions and methods do the following: i. Find the sum of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site