-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
threegradesoptions.py
70 lines (64 loc) · 1.6 KB
/
threegradesoptions.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
63
64
65
66
67
68
69
70
import math
def threeGrades():
grade = int(input("Enter grade between 1-100: "))
while grade < 1 or grade > 100:
grade = int(input("Enter grade between 1-100: "))
return grade
def averageGrade(grades):
total = 0
for grade in grades:
total += grade
average = total / len(grades)
return average
def maxGrade(grades):
max = grades[0]
for grade in grades:
if grade > max:
max = grade
return max
def minGrade(grades):
min = grades[0]
for grade in grades:
if grade < min:
min = grade
return min
def main():
grades = []
menu = """
1. Enter three grades:
2. Show Average
3. Show Highest Grade
4. Show Lowest Grade
5. Exit
"""
while True:
print(menu)
option = int(input("Enter Option: "))
if option == 1:
for i in range(3):
grades.append(threeGrades())
elif option == 2:
average = averageGrade(grades)
print("average = ", average)
if average >= 90:
print("The average grade is: A")
elif average >= 80:
print("The average grade is: B")
elif average >= 70:
print("The average grade is: C")
elif average >= 60:
print("The average grade is: D")
else:
print("The average grade is: F")
elif option == 3:
max = maxGrade(grades)
print("The Highest Grade is: ", max)
elif option == 4:
min = minGrade(grades)
print("The Lowest Grade is: ", min)
elif option == 5:
break
else:
print("error: Please Enter a Correct Choice!")
if __name__ == "__main__":
main()