I am confused


#1

https://www.codecademy.com/en/courses/learn-python/lessons/conditionals--control-flow/exercises/i-got--problems-but-a-switch-aint-one

So i decided to play around with the editor a bit and I am a little confused with something. The code is below. How come the function returns to -1? Shouldn’t it return to 0? In what ways does it satisfy the elif statement? Can someone explain this to me?

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

#2

0 is considered false and 1 is considered true:

if 0 == False:
    print "zero equals false"

computers only understand two things, off (false, 0) and on (1, true)


#3

Ohmagod I am dumb. How did I not realise this hahaha. Thank you very much.


#4

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