python if

Published onesixx on

https://wikidocs.net/2864

if 조건 :

블럭에 대한 표현은 { } 기호 대신, “들여쓰기”로 표현함.

>>> price=10000
>>> if price >= 10000:
... \tprint ("onesixx");
... \tprint ("indentation")
... 
onesixx
indentation

if 조건 : A else B

>> price=10000
>>> if price > 10000:
... \tprint("위")
... else:
... \tprint("아래")
... 
아래

if 조건 : A elif 조건 : B elif 조건 : C

>>> price=11000
>>> if price >= 10000:
... \tprint("위")
... elif price >=5000 and price < 10000:
... \tprint("중간")
... elif price < 5000:
... \tprint("아래")
... 
위
Categories: Python Basic

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x