Python
Python 개념 및 실습 - input
developers developing
2022. 9. 3. 09:00
1) input : 사용자에게 입력 받기
# 입력 : input()
# 화면에 보여주는건 print 사용
msg = input()
print(msg)


msg = input("이름 입력 : ")
print(msg)



num1 = input("Num1 : ")
num2 = input("Num2 : ")
print(num1 + num2)
#str 값으로 인식 문자열 연결

num1 = int(input("Num1 : "))
num2 = int(input("Num2 : "))
print(num1 + num2)
# 타입형변환 해주기

# 실습
년/월/일 형태로 입력 받은 후 10년 후 날짜를 출력하기
ex) 2022/05/20 입력받고 2032년 05월 20일
date1 = input("날짜입력(년/월/일) ")
pos = date1.find("/") #가장 처음에 찾은 /
year = int(date1[:pos]) + 10
print("입력한 날짜의 10년 후는 ? %s " % (str(year) + "년 " + date1[5:7]+"월 "+date1[8:] +"일"))


# 리스트형식
date1 = input("날짜입력(년/월/일) ")
date1 = date1.split("/")
print("입력한 날짜의 10년 후는 ? %s " % (str(int(date1[0])+10) + "년 " + date1[1]+"월 "+date1[2] +"일"))