Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags
more
Archives
Today
Total
관리 메뉴

꼬물꼬물 개발자

if, else, elif 본문

Python

if, else, elif

한고운 2024. 8. 23. 04:41

# 조건문1 : 조건문이 True면 다음 명령을 실행하라
a = "gowoon"

if a == "gowoon":
  print(f"{a}, 환영합니다!")

# 조건문2 : password가 True면 A실행, False면 B실행
password_correct = False

if password_correct:
  print("Here is your money") #A
else:
  print("Wrong password") #B

# 조건문3 : winner가 10보다 크면 A실행, 10보다 작으면 B실행, 10이면 C실행 
winner = 10

if winner > 10:
  print("Winner is greater than 10") #A
elif winner < 10:
  print("Winner is less than 10") #B
else:
  print("Winner is 10") #C


'Python' 카테고리의 다른 글

while  (0) 2024.08.30
input, and, or  (0) 2024.08.29
Return  (0) 2024.08.22
Functions  (0) 2024.08.22
Datatype  (0) 2024.08.21