I got 99 problems


#1

def greater_less_equal_5(answer):
if ________:
return 1
elif ________:
return -1
else:
return 0

print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

I must admit, I've been stuck on this very problem for a while and have extinguished my guesses. I'm sure it's easy but could you solve and explain please?


I got 99 problems
#2

I think it will be helpful for you as well, to post some of your 'guesses'so that we can see where you are coming from. :slight_smile:


#3

We want to be able to pass in any number and have our program tell us (as the name suggests) whether the number is greater than 5, less than 5 or equal to 5 (the default case).

What expressions should be written to fill in the blanks?


#4

def greater_less_equal_5(answer):
if "answer" > 5:
return 1
elif "answer" < 5:
return -1
else:
return 0

print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

let's start with this guess. I have many more, but all along these lines. I think I'm being hung up by trying to follow the example?


#5

if 8 > 9:
print "I don't get printed!"
elif 8 < 9:
print "I get printed!"
else:
print "I also don't get printed!"

this is the example btw


#6

def greater_less_equal_5(answer):
    if "answer" > 5:
         return 1
    elif "answer" < 5: 
         return -1
    else:
         return 0

This is what you said your guess was? Did you try it? If you did, what kind of error message did you get? I think that this is really close to what you would want to use, but i want you to look at your if/elif conditions, you're comparing a string, ("answer"), to a number, rather than the variable answer


#7

haha I feel so dumb. Thank you, changing it to a variable was correct


#8