Answer to Question #168532 in Python for Angelie Suarez

Question #168532

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: Victoria Jimenez


Filipino: 80 - Passed

Math: 74 - Failed

Science: 89 - Passed

English: 74 - Failed

PE: 90 - Passed


Hi Victoria Jimenez, Your Average Grade is 81.4 and you are PASSED!


*If the grade is failed the output should be


Hi Victoria Jimenez, Your Average Grade is 74.3 and you are FAILED!


1
Expert's answer
2021-03-03T02:07:26-0500
name = str(input("Enter your name: "))
n = int(input("Enter number of subjects: "))
count = 0
pass1 = 0
fail = 0
for i in range(n):
    sub_name = str(input("Enter subject name: "))
    grade = int(input("Enter grade in " + sub_name + ": "))
    count += grade
    if grade < 30:
        fail += 1
        print("FAILED")
    else:
        pass1 += 1
        print("PASSED")

avg = count/n

if pass1 > fail:
    print("Hi " + name + "Your Average Grade is " + str(avg) + " and you are PASSED!")
else:
    print("Hi " + name + "Your Average Grade is " + str(avg) + " and you are FAILED!")



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