了解如何在python中使用条件语句

时间:2017-07-23 03:46:24

标签: python

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行,填写if语句以检查答案是否大于5。 在第4行,填写elif,如果answer小于5,则函数输出-1。)

1 个答案:

答案 0 :(得分:0)

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)

试试这个