Answer to Question #331964 in Python for DjSnappy

Question #331964

Create a program the user will input 5 grades (choose any subjects and input any 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 - Failed



Science: 89 - Passed



English: 74 - Failed



*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 Grade



*If the average grade is <= 74 the output should be



YOU FAILED!

1
Expert's answer
2022-04-21T18:06:29-0400
name = input("Enter student name: ")
print("Please enter grades")
subjects = ["Math", "Physics", "Science", "Geography", "English"]
grades = [1, 1, 1, 1, 1]
sum = 0
failed_sub = []
for i in range(5):
    grades[i] = int(input(subjects[i] + ": "))
input("Please enter to continue")

print("Student Name: " + name)
for i in range(5):
    print(subjects[i] + ": " + str(grades[i]), end=' - ')
    if grades[i] < 75:
        print("Failed")
        failed_sub.append(subjects[i])
    else:
        print("Passed")
    sum += grades[i]
if sum/5 < 75:
    print("YOU FAILED!")
else:
    print("PASSED!")
    if len(failed_sub) == 1:
        print("You need to re-take in ")
    elif len(failed_sub) == 2:
        print("You need to re-take in " + failed_sub[0] + " Subject and " + failed_sub[1])
    elif len(failed_sub) == 3:
        print("You need to re-take in " + failed_sub[0] + " Subject, " + failed_sub[1] + " Subject and " + failed_sub[2])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS