len()
: 문자 길이를 반환fine()
: 특정 문자열의 위치를 찾아 반환isdigit()
: 숫자인지 확인(숫자이면 True, 아니면 False)datetime
현재 사용하고 있는 시스템의 날짜와 시간 정보를 알려줌
random
파이썬에서 난수를 생성할 때 사용하는 모듈
ex) random.randint(1,5)
: 1 ~ 5사이 정수 난수 생성
width = float(input('가로 길이 입력:'))
height = float(input('세로 길이 입력:'))
triangle_area = width * height / 2
square_area = width * height
# 소숫점 첫번째 자리까지
print('-'*25)
print('삼각형 넓이 :', triangle_area)
print('사각형 넓이 :', square_area)
# 정수형으로 출력
print('삼각형 넓이 : %d' % triangle_area)
print('사각형 넓이 : %d' % square_area)
print('삼각형 넓이 : %f' % triangle_area)
print('사각형 넓이 : %f' % square_area)
# 소숫점 두번째 자리까지
print('삼각형 넓이 : %.2f' % triangle_area)
print('사각형 넓이 : %.2f' % square_area)
print('-'*25)
weight = input('체중 입력(g): ')
height = input('신장 입력(cm): ')
if weight.isdigit():
weight = int(weight) / 10
if height.isdigit():
height = int(height) / 100
print(f'체중: {weight}kg')
print(f'신장: {height}m')
bmi = weight / (height * height)
print('BMI = %.2f' % bmi)
import datetime
today = datetime.datetime.today()
now_age = input('나이 입력 : ')
if now_age.isdigit():
after_age = 100 - int(now_age)
myhundred = today.year + after_age
print('{}년({}년후)에 100살!!'.format(myhundred, after_age))
"이 글은 제로베이스 데이터 취업 스쿨 강의 자료 일부를 발췌한 내용이 포함되어 있습니다."