[제로베이스] 데이터취업스쿨 11기_5주차

임동혁·2023년 2월 5일
0

zbdata

목록 보기
6/7

- 데이터와 변수 연습 문제

name = '홍길동'
product = '야구글러브'
orderNo = 2568956
payMethod = '신용카드'
productPrice = 110000
payPrice = 100000
usePoint = 10000
payDate = '2021/08/03 21:50:12'
payDiv = 6
payDivCategory = '무'
phone = '02-1234-5678'

print(name,'고객님 안녕하세요.')
print(name,'고객님의 주문이 완료되었습니다.')
print('다음은 주문건에 대한 상세 내역입니다.')
print('-' * 50)
print('상품명\t: ',product)
print('주문번호\t: ',orderNo)
print('결제방법\t: ',payMethod)
print('상품금액\t: ',productPrice)
print('결제금액\t: ',payPrice)
print('포인트\t: ',usePoint)
print('결제일시\t: ',payDate)
print('할부\t\t: ',payDiv)
print('할부유형\t: ',payDivCategory)
print('문의\t\t: ',phone)
print('-' * 50)
print('저희 사이트를 이용해 주셔서 감사합니다.')
  • len() : 문자 길이를 반환함
  • find() : 특정 문자열의 위치를 찾아 반환함

width = float(input('가로 길이 입력: '))
height = float(input('세로 길이 입력: '))
triArea = width * height * 1/2
squArea = width * height

print('-'*12, ' Result ', '-'*12)
print('삼각형 넓이 : %f' %triArea)
print('사각형 넓이 : %f' %squArea)
print('삼각형 넓이 : %.2f' %triArea)
print('사각형 넓이 : %.2f' %squArea)
print('-'*35)

name = input('이름 입력: ')
mail = input('메일 입력: ')
userId = input('아이디 입력: ')
password = input('패스워드 입력: ')
frontSocialNum = input('주민번호 앞자리 입력: ')
backSocialNum = input('주민번호 뒷자리 입력: ')
address = input('주소 입력: ')
pwStar = '*' * len(password)
bsstar = backSocialNum[0] + ('*' * 6)

print('-' * 30)
print(f'이름 : {name}')
print(f'메일 : {mail}')
print(f'아이디 : {userId}')
print(f'비밀번호 : {pwStar}')
print(f'주민번호 : {frontSocialNum} - {bsstar}')
print(f'주소 : {address}')
print('-' * 30)
  • isdigit() : 숫자인지 확인(숫자이면 True, 아니면 False)

weight = input("체중 입력(g) : ")
height = input("신장 입력(cm) : ")
if weight.isdigit() == True :
    weight = (float(weight)/1000)
if height.isdigit() == True :
    height = (float(height)/100)
BMI = (weight/(height * height))
print('체중: %.1fkg'%weight)
print('신장: %.2fm'%height)
print('BMI : %.2f'%BMI)

num1 = 10
num2 = 20
print('num1: {}, num2: {}'.format(num1,num2))

tempNum = num1
num1 = num2
num2 = tempNum
print('num1: {}, num2: {}'.format(num1,num2))


출처:제로베이스

midScore = input("중간 고사 점수: ")
finalScore = input("기말 고사 점수: ")

if midScore.isdigit() and finalScore.isdigit() :
    sumScore = int(midScore) + int(finalScore)
    avgScore = sumScore/2
    print('총점: %d, 평균: %.1f' %(sumScore,avgScore))
else :
    print('잘 못 입력했습니다.')


출처:제로베이스

choice = int(input('언어 선택(Choose your language): 1. 한국어\t 2.English'))

if choice == 1:
    print('1.샌드위치\t 2.햄버거\t 3.쥬스\t 4.커피\t 5.아이스크림')
elif choice == 2:
    print('1.Sandwich\t 2.Hamburger\t 3.Juice\t 4.Coffee\t 5.Ice cream')


출처:제로베이스

import datetime
today = datetime.datetime.today()
myAge = input('나이 입력 : ')

if myAge.isdigit():
    difAge = 100 - int(myAge)
    difYear = today.year + difAge
    print('{}년({}년후)에 100살!!'.format(difYear, difAge))
else :
    print('잘 못 입력했습니다.')
profile
데이터분석 지망생

0개의 댓글