The question, my answer, and the output is screenshotted here
Constraints:
0
=no ticket
1
=small ticket
2
=big ticket.
If speed is 60 or less, the result is 0. If speed is between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the result is 2. Unless it is your birthday -- on that day, your speed can be 5 higher in all cases.
My Code:
def caught_speeding(speed, is_birthday):
if speed > 80 or (speed > 85 and is_birthday):
return 2
return int((60 < speed <= 80) or (65 < speed <= 85 and is_birthday))
caught_speeding(65, True)
gives 1 but should be 0
caught_speeding(85, True)
gives 2 but should be 1
the other tests are ok. When I trace the code I cant seem to find the error