프로그래밍/Python
17. if(조건문)
mimi04
2023. 5. 22. 16:28
weather = input("오늘 날씨는 어때요? ")
if weather == "비" or weather == "눈": #if 조건문
print("우산을 챙기세요") #맞으면 출력
elif weather == "미세먼지": #if가 아닐시 else if
print("마스크를 챙기세요")
else: #둘 다 아닐 때 출력
print("준비물이 필요 없어요.")
temp = int(input("기온은 어때요? ")) #input은 문자형이므로 숫자 입력시 int를 붙여 정수형
if 30 <= temp:
print("너무 더워요.외출을 삼가주세요.")
elif 10 <= temp and temp < 30:
print("괜찮은 날씨에요.")
elif 0 <= temp < 10:
print("외투를 챙기세요.")
else:
print("너무 추워요. 나가지 마세요.")
반응형