Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 9 Online
OpenStudy (anonymous):

Problem: The Danger Panda roller coaster requires that riders be at least 1.6 meters tall and under 1.9 meters tall. Return True iff a person, whose height in meters is given as the argument, is allowed to ride the Danger Panda. My solution(code): def allow_rider(height): """(float) -> bool Return True iff height is within the height parameters. Maximum Height of rider: 1.9 meters Minimum Height of rider: 1.6 meters allow_rider(1.7) True allow_rider (1.4) False """ if (height >= 1.6 and height <= 1.9): return True else: return False

OpenStudy (anonymous):

Teachers comment: The following test cases failed: | | test_allow_rider_hair_too_tall - IncorrectReturnValue | | Think about what happens with values near 1.9.

OpenStudy (anonymous):

could somebody help me understand waht this means

OpenStudy (anonymous):

and what i have to do to correct it

OpenStudy (anonymous):

def rider(height): return (height >= 1.6) && (height < 1.9); There's no problem. The thing to know is that they value has to be LESS THAN 1.9, so if you use the less than operator its all good. The problem is that it says "if and only if they are at least 1.6 meters and UNDER 1.9 meters". "Under 1.9 meters" implies that it does not include 1.9 meters, but it will include 1.8999999... So that's what you want, I think. You could write it somewhat more concisely as such: def rider(height): return 1.6 <= height < 1.9

OpenStudy (anonymous):

alright thanks, if i messaged you through the other message thing do you think youd be able to help me with 2 more questions?

OpenStudy (anonymous):

i dont know.. maybe? i'll try;)

OpenStudy (anonymous):

alright thanks so much ill inbox them to you right now

OpenStudy (anonymous):

medal me first? ;)

OpenStudy (anonymous):

ye sure anything

OpenStudy (anonymous):

i sent the question to you

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!