Thursday, June 26, 2014

Day 82

Explored Python at CodeCademy. Worked on Python tutorial 14 of 15, Conditionals & Control Flow, I Got 99 Problems, But a Switch Ain't One! Some practice with "Elif" statement.

The code used:
def greater_less_equal_5(answer):
    if 5 < answer: 
        return 1
    elif 5 > answer:          
        return -1
    else:
        return 0
        
print greater_less_equal_5(4)
print greater_less_equal_5(5)
print greater_less_equal_5(6)

The interaction for this code looked like this:
-1
0
1

No comments:

Post a Comment