Conditional & Control Flow


#1

On line 2, fill in the if statement to check if answer is greater than 5.
On line 4, fill in the elif so that the function outputs -1 if answer is less than 5.
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

As far i know it's the instruction and given code.so what have you done?


#3

i don't know the answer, always my answer is wrong


#4

Well lets take your first if statement. "On line 2, fill in the if statement to check if answer is greater than 5." So we need to right a statement to check if answer > 5... so our if statement should look something like this then:

if answer > 5:

You can follow the other instructions and the example I gave you for the next one I am sure :smiley:


#5

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