Command & Development/Python

Python - 3

Richard.Ryu 2022. 5. 11. 16:47
반응형

1. 1~12월 계절

a = int(input("Press Month : "))

print("*"*50)

if a==3 or a==4 or a==5 : print("%d is Spring" % a)

elif a==6 or a==7 or a==8 : print("%d is Summer" % a)

elif a==9 or a==10 or a==11 : print("%d is Poul" % a)

elif a==12 or a==1 or a==2 : print("%d is Winter" % a)

else : print("Error Month")

print("*"*50)

2. 만나이 계산

print("*"*30)

year = int(input("Press year : "))

month = int(input("Press Month : "))

day = int(input("Press Day : "))

birth_year = int(input("Press Birth Year : "))

birth_month = int(input("Press Birth Month : "))

birth_Day = int(input("Press Birth Day : "))

if birth_month >=1 and birth_month<=9 :
    Now_Age = 2022 - birth_year
    
elif birth_month == 10 :
    if birth_Day >=1 and birth_Day <=19 :
        Now_Age = 2022-birth_year
    else : Now_Age = 2022 - birth_year - 1

elif birth_month >=11 :
    Now_Age= 2022 - birth_year -1
    
else : print("*"*30 + '\n'"Error")


print("Today : %d, %d, %d" %(year, month, day))
print("Birthday : %d, %d, %d " % (birth_year, birth_month, birth_Day))
print("Now Age : %d" % Now_Age)
print("*"*30)
반응형

'Command & Development > Python' 카테고리의 다른 글

[Python] Lotto 번호 생성  (0) 2023.03.29
Python - 4  (0) 2022.05.12
Python - 2  (0) 2022.05.10
Python - 1  (0) 2022.05.09
Python Installation  (0) 2022.02.11