PROGRAMMIN
G TIME WITH
DICTIONARY
Student will be able to:
To program using the data type list
LEARNING
in Python.
OBJECTIVE To find out the output of the given
code.
A program to calculate
PROGRAM 1
average marks of n
students where n is
entered by the user.
list1 = []
print("How many students marks you want to
enter: ")
n = int(input())
for i in range(0,n):
print("Enter marks of student",(i+1),":")
CODE marks = int(input())
list1.append(marks)
total = 0
for marks in list1:
total = total + marks
average = total / n
print("Average marks of",n,"students
Write a program to check if a
number is present in the list or
not. If the number is present,
PROGRAM 2 print the position of the number.
Print an appropriate message if
the number is not present in the
list.
list1 = [] #Create an empty list
print("How many numbers do you want to enter in the list: ")
maximum = int(input())
print("Enter a list of numbers: ")
for i in range(0,maximum):
n = int(input())
list1.append(n) #append numbers to the list
num = int(input("Enter the number to be searched: "))
CODE position = -1
for i in range (0, lin (list1)
if list1[i] == num: #number is present
position = i+1 #save the position of number
if position == -1 :
print("Number",num,"is not present in the list")
else:
print("Number",num,"is present at",position + 1, "position")
Write a program to allow user to perform any
those list operation given in a menu. The
menu is:
1. Append an element
2. Insert an element
3. Append a list to the given list
PROGRAM 3 4. Modify an existing element
5. Delete an existing element from its
position
6. Delete an existing element with a given
value
7. Sort the list in the ascending order
8. Sort the list in descending order