You decided to create a program to help your colleagues. Your program will receive as input two real numbers, the first representing the grade of papers and the second the grade of the regular exam. Considering that each of the two grades represents 50% of the final average, your program will display a message indicating the student's situation, which can be one of three:
a) Passed: if the final average is greater than or equal to six;
b) Perhaps with the substitutive test: if there is any possible grade in the substitutive test that allows the final average to be greater than or equal to six. Remembering that, as well as the grade of papers and regular exam, the maximum grade in the substitute exam is ten and that it can only substitute the grade of the regular exam, not the one of works;
c) Failed: if the final average is less than six and there is no possibility of recovery, even with the maximum grade in the substitute test.
papers = float(input())
test = float(input())
avg = (papers test) / 2
sub_test = 10
if avg >= 6:
print("passed")
elif test or papers or avg < 0:
if test == 0:
avg = (sub_test papers) / 2
print( "Perhaps with the substitutive test")
elif papers == 0 or avg < 6:
avg = avg
print( "failed")
I did it this way but my solution didn't pass the hidden tests, here are the examples of inputs and outputs
CodePudding user response:
def solve(a, b):
avg = (a b) / 2
if avg >= 6:
print('passed')
elif (a 10) / 2 >= 6:
print('Perhaps with the substitutive test')
else:
print('failed')