본문 바로가기
Python 배우기

if_statement.py

by 노화방지 Anti-aging Hairstyle 2016. 3. 8.
반응형
name = "John"
age = 17

if name == "John" or age == 17: # check that name is "John" or age is 17. If so print next 2 lines.
print("name is John")
print("John is 17 years old")

tasks = ['task1', 'task2'] # create new list

if tasks == []: # Print "empty" if the "tasks" list is empty.

print("empty")


산출물 (Output)


name is John
John is 17 years old



* The "if" keyword is used to form a conditional statement that executes some specified code after checking if its expression is True.
Python uses indentation to define code blocks.


반응형

'Python 배우기' 카테고리의 다른 글

for_loop.py  (0) 2016.03.09
else_elif.py  (0) 2016.03.09
boolean_order.py  (0) 2016.03.08
boolean_operators.py  (0) 2016.03.08
in_keyword.py  (0) 2016.03.08

댓글