원문 : 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:
이도저도 아닌경우
반응형
'Python > Python 어렵게 배우기' 카테고리의 다른 글
| Python 어렵게 배우기 - Exercise 32: Loops and Lists (0) | 2013.12.27 |
|---|---|
| Python 어렵게 배우기 - Exercise 31: Making Decisions (0) | 2013.12.26 |
| Python 어렵게 배우기 - Exercise 29: What If (0) | 2013.12.26 |
| Python 어렵게 배우기 - Exercise 28: Boolean Practice (0) | 2013.12.18 |
| Python 어렵게 배우기 - Exercise 27: Memorizing Logic (0) | 2013.12.18 |