-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program3.py
62 lines (41 loc) · 1.14 KB
/
Program3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Write a function in python which accept a list of marks
# of students and return the minimum mark,
# maximum mark and the average marks.
# Use the same function to test.
# list of the marks of students
mark_list = []
# loop for adding/appending marks to the list
for i in range(int(input(
"Enter the number of students: "
))):
marks = int(input("Enter the marks: "))
mark_list.append(marks)
print("The list of marks is: ", mark_list)
# function to find the highest marks obtained
def maximum(a=mark_list):
a = sorted(a)
print(
"The highest marks obtained is", a[-1]
)
# function to find the minimum
def minimum(a=mark_list):
a = sorted(a)
print(
"The lowest marks obtained is", a[0]
)
# function to find the average
def average(a=mark_list):
add = sum(a)
length = len(a)
average = (add/length)
print(
"The average of all the marks is"
"{:2f}".format(average)
)
# main function to call all the necessary functions at once
def call(a=mark_list):
minimum(a=mark_list)
maximum(a=mark_list)
average(a=mark_list)
# call the main function
call(mark_list)