def hello():
print("안녕!")
print("또 만나요!")
hello()
hello()
def bus_rate(age):
if age > 65:
print("무료로 이용하세요")
elif age > 20:
print("성인입니다.")
else:
print("청소년입니다")
bus_rate(27)
bus_rate(10)
bus_rate(72)
def bus_fee(age):
if age > 65:
return 0
elif age > 20:
return 1200
else:
return 0
money = bus_fee(28)
print(money)
def check_gender(pin):
print('여기를 수정하시오')
check_gender('150101-1012345')
check_gender('150101-2012345')
check_gender('150101-4012345')
A. 풀이
def check_gender(pin):
num = pin.split('-')[1][:1] # 변수생성
if int(num) % 2 == 0: # 정수로 변환
print('여성')
else:
print('남성')
check_gender('150101-1012345')
check_gender('150101-2012345')
check_gender('150101-4012345')