Code is copied!
Class 11 CBSE - Python Lists Programs
Python is designed to understand the user’s responsibility, the protocol, and the ethical issues related to the field of computing.
Python in class 11 for cbse is very handy when it comes to practice on computers but for the beginers there might be some errors and problems such as exception. But it's always advisable to practice program on computer than writing it on paper because it cherishes your practical skills , knowledge and typing speed and you'll come to know new things and if you want to be a software developer someday then its a must call for you.
Program 1: Write a Python program to find the sum and average of marks in 5 subjects.
Solution:
L1=[78,98,85,57,69] sum = L1[0]+L1[1]+L1[2]+L1[3]+L1[4] avg = sum/5 print("Average=", avg) print("Sum=",sum)
Program 2: Write a python program to find the maximum element in the list entered by the user.
Solution:
lst=[] num= int(input("How many numbers:")) for n in range(0,num): numbers= int(input("Enter the number=")) lst.append(numbers) print("Maximum number is:", max(lst))
Program 3: Write a Python program to display the frequency of all elements of the list.
Solution:
# frequency of an element in the list L= [3,21,5,6,3,8,21,6] print(L) L1=[] L2=[] for i in L: if i not in L2: L2.append(i) x=L.count(i) L1.append(x) print("Elememts" ,'\t\t\t',"Frequency") for i in range(len(L1)): print(L2[i], '\t\t\t\t', L1[i])
Program 4: Write a Python program to print all the positive numbers present in the list.
Solution:
# Python program to find positive numbers from a list L1 = [] length = int(input("Enter number of elements : ")) for i in range(0, length): value = int(input()) L1.append(value) # printing all positive values of the list print("All positive numbers of the list : ") for i in L1: if i >0: print(i , end = " ")
Program 5: Write a python program remove duplicate elements from the list.
Solution:
# declare list list1 = [10, 20, 10, 20, 30, 40, 30, 50] # declare another list list2 = [] # appending elements for n in list1: if n not in list2: list2.append(n) # printing the lists print ("Original list") print ("list1: ", list1) print ("List after removing duplicate elements") print ("list2: ", list2)