Help with this


#1



https://www.codecademy.com/courses/python-beginner-BxUFN/3/4?curriculum_id=4f89dab3d788890003000096#


im stuck


to solve the problem

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)


#2

answer (the function parameter) contains the value you supply when calling the function, look:

# function with answer parameter
def greater_less_equal_5(answer):
    print answer
        

# function calls with arguments
print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

see how the arguments get copied into the function parameter? This means, you can check if answer is greater or smaller then 5


#3

You need two comparison operators to complete your function. They are > (greater than) and < (less than).

Example:

x = 5
y = 7

if x < y:
    print("x is less than y")

#4

It took me about 15+ minutes to figure out using multiple combinations of numbers or letters compared (>, <) to the number 5. The letters compared to 5 were on the right track, though wrong, because the first half of the comparison is suppose to be a placeholder for any potential number that could be entered- think multi-user interface instead of checking to see if you "homework" answer is right.
Instead of a letter placeholder, the solution involves a word placeholder. Hint: compare the def line to the three print lines to find the word to use to compare (>, <) to 5.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.