Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
40 views7 pages

Programming Time With List

The document outlines programming objectives for students to learn list data types in Python. It includes three example programs: one for calculating average marks of students, another for checking the presence of a number in a list, and a third for performing various list operations based on a menu. Each program is accompanied by code snippets demonstrating the required functionality.

Uploaded by

myselfdoes.2022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views7 pages

Programming Time With List

The document outlines programming objectives for students to learn list data types in Python. It includes three example programs: one for calculating average marks of students, another for checking the presence of a number in a list, and a third for performing various list operations based on a menu. Each program is accompanied by code snippets demonstrating the required functionality.

Uploaded by

myselfdoes.2022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

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

You might also like