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 Developed by: KANNAN.S
#Register No: 212223230098
def max_marks(marks):
marks.sort()
large=marks[-1]
return large
ii) # To find the maximum marks using the list method max().
#Program Developed by: KANNAN.S
#Register No: 212223230098
def max_marks(marks):
large=max(marks)
return large
iii) # To find the maximum marks without using builtin functions.
#Program Developed by: KANNAN.S
#Register No: 212223230098
def max_marks(marks):
max_mark=0
for i in marks:
if i>max_mark:
max_mark=i
return max_mark
i) # To find the maximum of marks using the list method sort.
ii) # To find the maximum marks using the list method max().
iii) # To find the maximum marks without using builtin functions.
Thus the program to find the maximum of given numbers from the list is written and verified using python programming.