The user will input 5 grades. Determine individual subjects either passed or failed. Lastly, calculate the average grade and determine whether if passed or failed.
Sample output:
Student Name: Jessica
Math: 74
Science: 89.5
English: 74
Geography: 82
Filipino: 80
*Average Grades: 79.9
*If the average grade is >= 75 the output should be
PASSED!
*If the subject grade is below 74 the output should be
You need to re-take in Math Subject and English Subject
*If the average grade is <= 74 the output should be
YOU FAILED!
grades = []
retake = []
name = input("Input name: ")
subjects = ["Math", "Science", "English", "Geography", "Filipino"]
print("input 5 grades:")
for i in subjects:
print(f"{i}: ", end='')
grades.append(int(input()))
avg = 0
for i in range(5):
avg += grades[i]
if grades[i] < 74:
retake.append(subjects[i])
avg = avg/5
print(f"Average Grades: {avg}")
if avg >= 75:
print("PASSED!")
else:
print("YOU FAILED!")
if len(retake)>0:
print("You need to re-take in ", end='')
for i in range(len(retake)):
if i > 0:
print(f" and {retake[i]} Subject", end='')
else:
print(f"{retake[i]} Subject", end='')
Comments
Leave a comment