To write a program to find the maximum of a list of numbers.
- Hardware – PCs
- Anaconda – Python 3.7 Installation / Moodle-Code Runner
- Get the list of marks as input
- Use the sort() function or max() function or use the for loop to find the maximum mark.
- Return the maximum value
i) # To find the maximum of marks using the list method sort.
'''
Program to mark the maximum of marks using the list method sort
Developed by: P.Hemasonica
RegisterNumber:
'''
def max_marks(marks):
marks.sort()
large = marks[-1]
return large
ii) # To find the maximum marks using the list method max().
'''
Program to find the maximum marks using the list method max().
Developed by: P.Hemasonica
RegisterNumber: 22003246
'''
def max_marks(list):
max=list[0]
for i in list:
if i>max:
max = i
return max
max_marks([88,67,77,93,95,11,67,89,56,89])
iii) # To find the maximum marks without using builtin functions.
'''
Program to the maximum marks without using builtin functions.
Developed by: P.Hemasonica
RegisterNumber: 22003264
'''
def max_marks(marks):
marks.sort()
large = marks[-1]
return large
Thus the program to find the maximum of given numbers from the list is written and verified using python programming.