[Python 기초 문제풀이]
-데이터와 변수 (02-05)
데이터와 변수(02)
- 원의 넓이:반지름 x 반지름 x 3.14
- 원의 둘레:반지름 x 2 x 3.14
데이터와 변수(03)
# 1.문자열-> '*'로 표기하는 방법 password=input('비밀번호 입력:') passwordStr= ' *' * len(password) print('초기 비밀번호 : {} '.format(password)) print('변경 비밀번호 : {} '.format(passwordStr)) 비밀번호 입력:879879 초기 비밀번호 : 879879 변경 비밀번호 : * * * * * * ➜ input 입력 시, input(X)의 x는 str타입 len 함수를 이용해서 x문자열의 길이를 구하고, 길이의 수만큼 곱하기 # 2.인덱싱 이용하여,문자열 변경하는 방법 # 문자열 요솟값 자체는 변경이 어려우므로 하단의 방법 이용 num1='990823' num2='2044111' num2R=num2[0] + ('*' * 6) print('변경 전 주민번호 : {} - {} '.format(num1,num2)) print('변경 후 주민번호: {} - {} '.format(num1,num2R)) 변경 전 주민번호 : 990823 - 2044111 변경 후 주민번호: 990823 - 2******데이터와 변수(04)
# isdigit() ➜ 숫자인지 확인(숫자는 True,아니면 False) weight=input('체중 입력(g): ') height=input('신장 입력(cm): ') if weight.isdigit() and height.isdigit(): weight=int(weight) height=int(height) ...데이터와 변수(05)
#오늘의 년,월,일 시간 상세 데이터 확인 시, datetime모듈 사용하기 import datetime today = datetime.datetime.today() print(today) 2023-06-04 22:24:17.674765