I just have a quick question to fully understand this simple boolean code.
If the movie rating is less than or equal to 5 prints something, if it is less than 9, prints something else. Fine. But 4 is less than 5 AND less than 9. Wouldn’t that rating print “Avoid at all costs” and “This one was fun”?
Sorry for my ignorance I am very new at coding, and thank you in advance.
Write your movie_review function here:
def movie_review(rating):
if(rating <= 5):
return “Avoid at all costs!”
if(rating < 9):
return “This one was fun.”
return “Outstanding!”
Uncomment these function calls to test your movie_review function:
Yes, that is so, however since we return for the first test, that value will have been processed and the second if will never be seen since we’ve exited the function.