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
관리 메뉴

꼬물꼬물 개발자

input, and, or 본문

Python

input, and, or

한고운 2024. 8. 29. 23:55
# 음주 가능 나이 계산기
# input 함수
age = input("How old are ypu?")
print("user answer", age)

# type 함수
print(type(age))

print("-------------")

# type 변경
age = int(input("How old are ypu?"))

# and : 조건이 모두 True 이면 True
# or :  조건이 하나만 True 여도 True
if age < 18:
  print("You can't drink.")
elif age >= 18 and age <= 35:
  print("You drink beer!")
elif age == 60 or age == 70:
  print("Birthday party!")
else:
  print("Go ahead!")

결과

'Python' 카테고리의 다른 글

list, tuples, dictionary  (0) 2024.08.31
while  (0) 2024.08.30
if, else, elif  (0) 2024.08.23
Return  (0) 2024.08.22
Functions  (0) 2024.08.22