number = []#this is an empty list
print(number)
number = ["student", 1,2,"list"]
print(number)
[] ['student', 1, 2, 'list']
#now lets add one more element to the list
number.append("table")#this will add another element
print(number)
['student', 1, 2, 'list', 'table']
#len function helps to find the number of elements in the list
len(number)
5
#finding average of marks scored by a class students
n=int(input("Enter the number of students in the class: "))
marks=[]
i=0
while i<n:
a = float(input("enter marks "))
marks.append(a)
i=i+1
avg = sum(marks)/len(marks) #sum(listname) gives the sum of all elements in the list and len(listname) gives the number of elements in the list
print("average marks :", avg)
Enter the number of students in the class: 5 enter marks 20 enter marks 30 enter marks 56 enter marks 45 enter marks 09 average marks : 32.0
#we use pop to remove an element from the list
a=[1,2,3,4]
a.pop()
print(a)
[2, 3, 4]