A student sitting 3 exams will pass if:
- They pass all subjects at 40 points and above, or
- They pass at least two subjects at 40 points or above, and the overall average is strictly greater than 50 points.
Write a function that takes three arguments of the three marks (integers), determines whether a student has passed or not based on the exam scores, and prints "This student has passed." or "This student has not passed."
My attempt at the function is below:
def student_pass(score1, score2, score3):
if (score1 >= 40) and (score2 >= 40) and (score3 >= 40):
print ("This student has passed.")
elif ((score1 >= 40 and score2 >= 40) or (score1 >= 40 and score3 >= 40) or (score2 >= 40 and score3 >= 40)) and ((score1+score2+score3)/3 >= 50):
print ("This student has passed.")
else:
print ("This student has not passed.")However, when I try to produce a "This student has not passed." statement with the inputs student_pass(70,50,30) I still get a "This student has passed." statement.
What could be the problem here?
Aucun commentaire:
Enregistrer un commentaire