본문 바로가기

Python/Python 어렵게 배우기

Python 어렵게 배우기 - Exercise 30: Else and If

원문 : http://learnpythonthehardway.org/book/ex30.html


if 문에대해 더 자세히 알아보자 (ex30.py)

people = 30
cars = 40
buses = 15


if cars > people:
    print "We should take the cars."
elif cars < people:
    print "We should not take the cars."
else:
    print "We can't decide."

if buses > cars:
    print "That's too many buses."
elif buses < cars:
    print "Maybe we could take the buses."
else:
    print "We still can't decide."

if people > buses:
    print "Alright, let's just take the buses."
else:
    print "Fine, let's stay home then."



결과



알 수 있는 내용

if 조건 :

    true일 경우

elif 조건2:

    true일 경우

else:

    이도저도 아닌경우


반응형