list manipulation in python class 11 programs

Python Programming
3 min readFeb 4, 2021

list manipulation in python class 11 programs

list manipulation in python class 11 programs

[list manipulation in python class 11 programs with sample run]

Q1. program to print elements of list[‘q’, ‘w’, ‘e’, ‘r’, ‘t’, ‘y’] in separate lines along with element’s both indexes (positive and negative)

program :-

L=[‘q’, ‘w’, ‘e’, ‘r’, ‘t’, ‘y’]
length=len(L)
for a in range(length):
print(“At indexes”, a, “and”,(a-length),”element :”,L[a])

Sample run above program is :

1.At indexes 0 and -6 element : q
2. At indexes 1 and -5 element : w
3. At indexes 2 and -4 element : e
4. At indexes 3 and -3 element : r
5. At indexes 4 and -2 element : t
6. At indexes 5 and -1 element : y

Q2. Program to find minimum element from a list of element along with its index in list.

lst = eval(input(“Enter list :”))
length = len(lst)
min_ele = lst[0]
min_index = 0
for i in range(1, length-1) :
if lst[i] < min_ele :
min_ele = lst[i]
min_index = i
print(“Given list is :”, lst)
print(“The minimum element of the given list is:”)
print(min_ele, “at index”, min_index)

Sample run of above program is :

Enter list : [2, 3, 4, -2, 6, -7, 8, 11, -9, 11]
Given list is : [2, 3, 4, -2, 6, -7, 8, 11, -9, 11]
The minimum element of fiven list is :
-9 at index 8

Q3. Program to calculate mean of a given list of numbers.

lst = eval(input(“Enter list :”))
length= len(lst)
mean = sum = 0
for i in range(0, length-1) :
sum += lst[i]
mean = sum/length
print(“Given list is :”, lst)
print(“The mean of the given list is :”, mean)

Sample run of above program is :

Enter list : [7, 23, -11, 55, 13.5, 20.05, -5.5]
Given list is : [7, 23, -11, 55, 13.5, 20.05, -5.5]
The mean of the given list is : 15.364285714285714

Q4. Program to search for an element in given list of numbers.

lst = eval(input(“Enter list :”))
length= len(lst)
element = int(input(“Enter element to be searched for :”))
for i in range(0, length-1) :
if element == lst[i] :
print(element, “found at index”, i)
break
else : #else of for loop
print(element, “not found in given list”)

Sample run of above program is :

Enter list : [2, 8, 9, 11, -55, -11, 22, 78, 67]
Enter element to be searched for : -11
-11 found at index 5

Q5. Program to count frequency of a given element in a list of numbers.

lst = eval(input(“Enter list :”))
length= len(lst)
element = int(input(“Enter element :”))
count = 0
for i in range(0, length-1) :
if element == lst[i] :
count += 1
if count == 0 :
print(element, “not found in given list”)
else :
print(element, “has frequency as”, count, “in given list”)

Sample run of above program is :

Enter list : [1, 1, 1, 2, 2, 3, 4, 2, 2, 5, 5, 2, 2, 5]
Enter element : 2
2 has frequency as 6 in given list

for more programs : click here

Originally published at https://kamalsinghstarbooks.xyz on February 4, 2021.

--

--