customerName = '홍길동'
productName = '야구글러브'
orderNum = 2568956
purchaseMethod = '신용카드'
productPrice = format(110000, ',')
pricePaid = format(100000, ',')
rewardPoint = 10000
purchaseDate = '2021/08/03 21:50:12'
monthlyInstallment = 6
typeInstallment = '무'
print("{} 고객님 안녕하세요.".format(customerName))
print('{} 고객님의 주문이 완료되었습니다.'.format(customerName))
print('다음은 주문건에 대한 상세 내역입니다.')
print('*' * 25)
print('상품명\t: {}'.format(productName))
print('주문번호\t: {}'.format(orderNum))
print('결재방법\t: {}'.format(purchaseMethod))
print('상품금액\t: {} 원'.format(productPrice))
print('결재금액\t: {} 원'.format(pricePaid))
print('포인트\t: {} P'.format(rewardPoint))
print('결재일시\t: {}'.format(purchaseDate))
print('할부\t\t: {} 개월'.format(monthlyInstallment))
print('할부유형\t: {}'.format(typeInstallment))
print('문의 : 02-1234-5678')
print('*' * 25)
print('저희 사이트를 이용해 주셔서 감사합니다.')
msg = input('메시지 입력 : ')
msgCnt = len(msg)
print('메시지 문자열 길이 : {}'.format(msgCnt))
userMsg = input('메시지 입력 : ')
print('메시지 문자열 길이 : {}'.format(len(userMsg)))
파이썬(영어: Python)은 1991년 프로그래머인 귀도 반 로섬이 발표한 고급 프로그래밍 언어로, 플랫폼에 독립적이며 인터프리터식, 객체지향적, 동적 타이핑(dynamically typed) 대화형 언어이다. 파이썬이라는 이름은 귀도가 좋아하는 코미디 〈Monty Python's Flying Circus〉에서 따온 것이다.
article = '파이썬(영어: Python)은 1991년 프로그래머인 귀도 반 로섬이 발표한 고급 프로그래밍 언어로, ' \
'플랫폼에 독립적이며 인터프리터식, 객체지향적, 동적 타이핑(dynamically typed) 대화형 언어이다. ' \
'파이썬이라는 이름은 귀도가 좋아하는 코미디 〈Monty Python\'s Flying Circus〉에서 따온 것이다.'
strIdx = article.find('객체지향')
print('\'객체지향\' 문자열 위치: {}'.format(strIdx))
width = float(input('가로 길이 입력 : '))
height = float(input('세로 길이 입력 : '))
triArea = width * height / 2
sqrArea = width * height
print('-' * 10, 'Result', '-' * 10)
print('삼각형 넓이 : %f' % triArea)
print('사각형 넓이 : %f' % sqrArea)
print('삼각형 넓이 : %.2f' % triArea)
print('사각형 넓이 : %.2f' % sqrArea)
print('-' * 28)
pi = 3.14
radius = float(input('반지름(cm) 입력 : '))
circleArea = pow(radius, 2) * pi
circleCircumference = radius * 2 * pi
print('원의 넓이\t\t: %dcm' % circleArea)
print('원의 둘레길이\t: %dcm' % circleCircumference)
print('원의 넓이\t\t: %.1fcm' % circleArea)
print('원의 둘레길이\t: %.1fcm' % circleCircumference)
print('원의 넓이\t\t: %.3fcm' % circleArea)
print('원의 둘레길이\t: %.3fcm' % circleCircumference)
userName = input('이름 입력 : ')
emailAddr = input('메일 입력 : ')
idInput = input('아이디 입력 : ')
pwInput = len(input('비밀번호 입력 : '))
socialSecurityNum1 = int(input('주민번호 앞자리 입력 : '))
socialSecurityNum2 = input('주민번호 뒷자리 입력 : ')
currentAddr = input('주소 입력 : ')
print('-' * 25)
print('이름 : {}'.format(userName))
print('메일 : {}'.format(emailAddr))
print('아이디 : {}'.format(idInput))
print('비밀번호 : {}'.format('*' * pwInput))
print('주민번호 : {} - {}{}'.format(socialSecurityNum1, socialSecurityNum2[0], ('*' * (len(socialSecurityNum2) - 1))))
print('주소 : {}'.format(currentAddr))
print('-' * 25)
name = input('이름 입력 : ')
mail = input('메일 입력 : ')
id = input('아이디 입력 : ')
pw = input('비밀번호 입력 : ')
privateNumber1 = input('주민번호 앞자리 입력 : ')
privateNumber2 = input('주민번호 뒷자리 입력 : ')
address = input('주소 입력 : ')
print('-' * 25)
print('이름 : {}'.format(userName))
print('메일 : {}'.format(emailAddr))
print('아이디 : {}'.format(idInput))
print('비밀번호 : {}'.format('*' * pwInput))
print('주민번호 : {} - {}{}'.format(socialSecurityNum1, socialSecurityNum2[0], ('*' * (len(socialSecurityNum2) - 1))))
print('주소 : {}'.format(currentAddr))
print('-' * 25)
# BMI Function : 몸무게(kg) / 신장(M)^2
weight = input('체중 입력(g) : ')
height = input('신장 입력(cm) : ')
if weight.isdigit():
weight = int(weight) / 10
if height.isdigit():
height = int(height) / 100
print('체중 : {}kg'.format(weight))
print('신장 : {}m'.format(height))
bmi = weight / pow(height,2)
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():
midScore = int(midScore)
finalScore = int(finalScore)
totalScore = midScore + finalScore
avgScore = totalScore / 2
print('총점 : {}, 평균 : {}'.format(totalScore,avgScore))
else:
print('잘못 입력하셨습니다.')
inputLang = input('언어 선택(Choose your language) : 1.한국어\t2.English\t')
if inputLang.isdigit():
inputLang = int(inputLang)
if inputLang == 1:
print('1.샌드위치\t2.햄버거\t3.쥬스\t4.커피\t5.아이스크림')
elif inputLang == 2:
print('1.Sandwich\t2.Hamburger\t3.Juice\t4.Coffee\t5.Ice Cream')
else:
print('잘못 고르셨습니다. 다시 입력해주세요.')
else:
print('잘못 입력하셨습니다. 다시 입력해주세요.')
-예시 답안 :
selectNumber = input('언어 선택(Choose your language) : 1.한국어\t2.English\t')
if selectNumber == '1':
menu = '1.샌드위치\t2.햄버거\t3.쥬스\t4.커피\t5.아이스크림'
elif selectNumber == '2':
menu = '1.Sandwich\t2.Hamburger\t3.Juice\t4.Coffee\t5.Ice Cream'
print(menu)
import datetime
today = datetime.datetime.today()
myAge = input('나이 입력 : ')
if myAge.isdigit():
afterAge = 100 - int(myAge)
myHundred = today.year + afterAge
print('{}년({}년후)에 100살!!'.format(myHundred, afterAge))
else:
print('잘 못 입력했습니다.')
money50000 = 50000; money10000 = 10000; money5000 = 5000
money1000 = 1000; money500 = 500; money100 = 100; money10 = 19
money50000Cnt = 0; money10000Cnt = 0; money5000Cnt = 0
money1000Cnt = 0; money500Cnt = 0; money100Cnt = 0; money10Cnt = 0
productPrice = int(input('상품 가격 입력 : '))
paidPrice = int(input('지불 금액 : '))
if paidPrice > productPrice:
changeMoney = paidPrice - productPrice
changeMoney = (changeMoney // 10) * 10
print('거스름 돈 : {}(원단위 절사)'.format(changeMoney))
if changeMoney > money50000:
money50000Cnt = changeMoney // money50000
changeMoney %= money50000
if changeMoney > money10000:
money10000Cnt = changeMoney // money10000
changeMoney %= money10000
if changeMoney > money5000:
money5000Cnt = changeMoney // money5000
changeMoney %= money5000
if changeMoney > money1000:
money1000Cnt = changeMoney // money1000
changeMoney %= money1000
if changeMoney > money500:
money500Cnt = changeMoney // money500
changeMoney %= money500
if changeMoney > money100:
money100Cnt = changeMoney // money100
changeMoney %= money100
if changeMoney > money10:
money10Cnt = changeMoney // money10
changeMoney %= money10
print('-' * 30)
print('50,000 {}장'.format(money50000Cnt))
print('10,000 {}장'.format(money10000Cnt))
print('5,000 {}장'.format(money5000Cnt))
print('1,000 {}장'.format(money1000Cnt))
print('500 {}개'.format(money500Cnt))
print('100 {}개'.format(money100Cnt))
print('10 {}개'.format(money10Cnt))
print('-' * 30)
korScore = int(input('국어 점수 입력 : '))
engScore = int(input('영어 점수 입력 : '))
mathScore = int(input('수학 점수 입력 : '))
totalScore = korScore + engScore + mathScore
avgScore = totalScore / 3
bestScore = korScore
bestSubj = '국어'
if engScore > bestScore:
bestScore = engScore
bestSubj = '영어'
if mathScore > bestScore:
bestScore = mathScore
bestSubj = '수학'
worstScore = korScore
worstSubj = '국어'
if engScore < worstScore:
worstScore = engScore
worstSubj = '영어'
if mathScore < worstScore:
worstScore = mathScore
worstSubj = '수학'
bestWorstDiff = bestScore - worstScore
print('총점 : {}'.format(totalScore))
print('평균 : %.2f' % avgScore)
print('-' * 30)
print('최고 점수 과목(점수) : {}({})'.format(bestSubj, bestScore))
print('최저 점수 과목(점수) : {}({})'.format(worstSubj, worstScore))
print('최고, 최저 점수 차이 : {}'.format(bestWorstDiff))
hou = int(input('시간 입력 : '))
min = int(input('분 입력 : '))
sec = int(input('초 입력: '))
print('{}초'.format(format(hou * pow(60,2) + min * 60 + sec, ',')))
price = int(input('금액 입력 : '))
interestRate = float(input('이율 입력 : '))
timePeriod = int(input('기간 입력 : '))
func = price * pow((1 + interestRate / 100), timePeriod)
adjFunc = format(int(func), ',')
print('-' * 30)
print('이율 : %.1f%%' % interestRate)
print('원금 : {}원'.format(format(price, ',')))
print('{}년 후 금액 : {}원'.format(timePeriod, adjFunc))
print('-' * 30)
money = int(input('금액 입력 : '))
rate = float(input('이율 입력 : '))
term = int(input('기간 입력 : '))
targetMoney = money
for i in range(term):
targetMoney *= (targetMoney * rate * 0.01)
targetMoneyFormatted = format(int(targetMoney), ',')
print('-' * 30)
print('이율 : {}%'.format(rate))
print('원금 : {}원'.format(money))
print('{}년 후 금액 : {}원'.format(term, targetMoneyFormatted))
print('-' * 30)
baseTemp = 29
step = 60
stepTemp = 0.8
height = int(input('고도 입력 : '))
targetTemp = baseTemp - (height // step * 0.8)
if height % step != 0:
targetTemp -= stepTemp
print('지면 온도 : {}'.format(baseTemp))
print('고도 {}m의 기온 : {}'.format(height, targetTemp))
bread = 197
milk = 152
studentCnt = 17
print('학생 한 명이 갖게 되는 빵 개수 : {}'.format(bread // studentCnt))
print('학생 한 명이 갖게 되는 우유 개수 : {}'.format(milk // studentCnt))
print('남는 빵 개수 : {}'.format(bread % studentCnt))
print('남는 우유 개수 : {}'.format(milk % studentCnt))
inputAge = int(input('나의 나이 입력 : '))
if inputAge <= 19 or inputAge >= 65:
endNum = int(input('출생 연도 끝자리 입력 : '))
if endNum == 1 or endNum == 6:
print('월요일 접종 가능!')
elif endNum == 2 or endNum == 7:
print('화요일 접종 가능!')
elif endNum == 3 or endNum == 8:
print('수요일 접종 가능!')
elif endNum == 4 or endNum == 9:
print('목요일 접종 가능!')
elif endNum == 5 or endNum == 0:
print('금요일 접종 가능!')
else:
print("하반기 일정 확인하세요.")
byInch = 0.039
lengthMM = int(input('길이(mm) 입력 : '))
lengthInch = lengthMM * byInch
print('{}mm -> {}inch'.format(lengthMM, lengthInch))
speedLimit = 50
inputSpeed = int(input('속도 입력 : '))
if inputSpeed <= speedLimit:
print('안전속도 준수!!')
if inputSpeed > speedLimit:
print('안전속도 위반!! 과태료 50,000원 부과 대상!!')
message = input('메시지 입력 : ')
priceSMS = 50
priceMMS = 100
messageLen = len(message)
if messageLen <= 50:
print('SMS 발송!!')
print('메시지 길이 : {}'.format(messageLen))
print('메시지 발송 요금 : {}'.format(priceSMS))
else:
print('MMS 발송!!')
print('메시지 길이 : {}'.format(messageLen))
print('메시지 발송 요금 : {}'.format(priceMMS))
message = input('메시지 입력 : ')
lenMessage = len(message)
msgPrice = 50
if lenMessage <= 50:
msgPrice = 50
print('SMS 발송!!')
else:
msgPrice = 100
print('MMS 발송!!')
print('메시지 길이 : {}'.format(lenMessage))
print('메시지 발송 요금 : {}'.format(msgPrice))
korScoreAvg = 85; engScoreAvg = 82
mathScoreAvg = 89; histScoreAvg = 94; sciScoreAvg = 75
avgTotalScore = korScoreAvg + engScoreAvg + \
mathScoreAvg + histScoreAvg + sciScoreAvg
avgAvgScore = int(avgTotalScore / 5)
korScore = int(input('국어 점수 : '))
engScore = int(input('영어 점수 : '))
mathScore = int(input('수학 점수 : '))
histScore = int(input('국사 점수 : '))
sciScore = int(input('과학 점수 : '))
totalScore = korScore + engScore + \
mathScore + histScore + sciScore
avgScore = int(totalScore / 5)
korScoreGap = korScore - korScoreAvg
engScoreGap = engScore - engScoreAvg
mathScoreGap = mathScore - mathScoreAvg
histScoreGap = histScore - histScoreAvg
sciScoreGap = sciScore - sciScoreAvg
totalScoreGap = totalScore - avgTotalScore
avgScoreGap = avgScore - avgAvgScore
print('-' * 70)
print('총점 : {}({}), 평균 : {}({})'.format(totalScore, totalScoreGap, avgScore, avgScoreGap))
print('국어 : {}({}), 영어 : {}({}), 수학 : {}({}), 국사 : {}({}), 과학 : {}({})'.format(
korScore, korScoreGap, engScore, engScoreGap, mathScore, mathScoreGap, histScore, histScoreGap, sciScore, sciScoreGap
))
print('-' * 70)
str = '+' if korScoreGap > 0 else '-'
print('국어 편차 : {}({})'.format(str * abs(korScoreGap), korScoreGap))
str = '+' if engScoreGap > 0 else '-'
print('영어 편차 : {}({})'.format(str * abs(engScoreGap), engScoreGap))
str = '+' if mathScoreGap > 0 else '-'
print('수학 편차 : {}({})'.format(str * abs(mathScoreGap), mathScoreGap))
str = '+' if histScoreGap > 0 else '-'
print('국사 편차 : {}({})'.format(str * abs(histScoreGap), histScoreGap))
str = '+' if sciScoreGap> 0 else '-'
print('과학 편차 : {}({})'.format(str * abs(sciScoreGap), sciScoreGap))
str = '+' if totalScoreGap> 0 else '-'
print('총점 편차 : {}({})'.format(str * abs(totalScoreGap), totalScoreGap))
str = '+' if avgScoreGap> 0 else '-'
print('평균 편차 : {}({})'.format(str * abs(avgScoreGap), avgScoreGap))
print('-' * 70)
import random
comNum = random.randint(1, 2)
userSelect = int(input('홀/짝 선택 : 1.홀 \t2.짝 '))
if comNum == 1 and userSelect == 1:
print('빙고!! 홀수!!!')
elif comNum == 2 and userSelect == 2:
print('빙고!! 짝수!!!')
elif comNum == 1 and userSelect == 2:
print('실패!! 홀수!!!')
elif comNum == 2 and userSelect == 1:
print('실패!! 짝수!!!')
import random
comNumber = random.randint(1, 3)
userNumber = int(input('가위, 바위, 보 선택 : 1.가위\t2.바위\t3.보 '))
if (comNumber == 1 and userNumber == 1) or (comNumber == 2 and userNumber == 3) or (comNumber == 3 and userNumber == 1):
print('컴퓨터 : 패,\t유저 : 승')
elif comNumber == userNumber:
print('무승부')
else:
print('컴퓨터 : 승,\t유저 : 패')
print('컴퓨터 : {},\t유저 : {}'.format(comNumber, userNumber))
classification = int(input('업종 선택 (1.가정용\t\t2.대중탕용\t3.공업용): '))
waterUse = int(input('사용량 입력 : '))
print('=' * 30)
print('상수도 요금표')
print('-' * 30)
print('사용량\t:\t요금')
if classification == 1:
print('{}\t\t:\t{}원'.format(waterUse, format(waterUse * 540, ',')))
elif classification == 2:
if waterUse > 300:
print('{}\t\t:\t{}원'.format(waterUse, format(waterUse * 2400, ',')))
elif waterUse <=300 and waterUse >50:
print('{}\t\t:\t{}원'.format(waterUse, format(waterUse * 1920, ',')))
else:
print('{}\t\t:\t{}원'.format(waterUse, format(waterUse * 820, ',')))
elif classification == 3:
if waterUse > 500:
print('{}\t\t:\t{}원'.format(waterUse, format(waterUse * 470, ',')))
else:
print('{}\t\t:\t{}원'.format(waterUse, format(waterUse * 240, ',')))
print('=' * 30)
part = int(input('업종 선택 (1.가정용\t\t2.대중탕용\t3.공업용): '))
useWater = int(input('사용량 입력 : '))
unitPrice = 0
if part == 1:
unitPrice = 540
elif part == 2:
if useWater > 300:
unitPrice = 2400
elif useWater <= 300 and useWater > 50:
unitPrice = 1920
elif useWater <= 50:
unitPrice = 820
elif part == 3:
if useWater > 500:
unitPrice = 470
else:
unitPrice = 240
print('=' * 30)
print('상수도 요금표')
print('-' * 30)
print('사용량\t:\t요금')
userPrice = useWater * unitPrice
print('{}\t\t:\t{}원'.format(useWater, format(userPrice, ',')))
print('=' * 30)
import datetime
today = datetime.datetime.today()
day = today.day
limitDust = 150
dustNum = int(input('미세먼지 수치 입력 : '))
carType = int(input('차량 종류 선택 : 1. 승용차\t2. 영업용차\t'))
carNum = int(input('차량 번호 입력 : '))
print('-' * 30)
print(today)
print('-' * 30)
if dustNum > limitDust and carType == 1:
if (day % 2) == (carNum % 2):
print('차량 2부제 적용')
print('차량 2부제로 금일 운행제한 대상 차량입니다.')
else:
print('금일 운행 가능합니다.')
elif dustNum > limitDust and carType == 2:
if (day % 5) == (carNum % 5):
print('차량 5부제 적용')
print('차량 5부제로 금일 운행제한 대상 차량입니다.')
else:
print('금일 운행 가능합니다.')
elif dustNum <= limitDust:
if (day % 5) == (carNum % 5):
print('차량 5부제 적용')
print('차량 5부제로 금일 운행제한 대상 차량입니다.')
else:
print('금일 운행 가능합니다.')
print('-' * 30)
import random
randomNum = random.randint(1, 1001)
tryNum = 0
gameFlag = True
while gameFlag:
tryNum += 1
userNum = int(input('1에서 1000까지의 정수 입력 : '))
if randomNum == userNum:
print('빙고!')
gameFlag = False
else:
if randomNum >= userNum:
print('난수가 크다!')
else:
print('난수가 작다!')
print('난수 : {}, 시도 횟수 : {}'.format(randomNum, tryNum))
indoorTemp = int(input('실내온도 입력 : '))
if indoorTemp > 28:
print('에어컨: 매우 강!!')
elif indoorTemp > 26 and indoorTemp <= 28:
print('에어컨: 강!!')
elif indoorTemp > 24 and indoorTemp <= 26:
print('에어컨: 중!!')
elif indoorTemp > 22 and indoorTemp <= 24:
print('에어컨: 약!!')
elif indoorTemp > 18 and indoorTemp <= 22:
print('에어컨: 매우 약!!')
elif indoorTemp <= 18:
print('에어컨: OFF!!')
for i in range(1, 101):
if i <= 9:
if i % 2 == 0:
print('[{}]: 짝수!'.format(i))
else:
print('[{}]: 홀수!'.format(i))
else:
num10 = i // 10
num1 = i % 10
result10 = ''
if num10 % 2 == 0:
result10 = '짝수'
else:
result10 = '홀수'
result1 = '0'
if num1 != 0:
if num1 % 2 == 0:
result1 = '짝수'
else:
result1 = '홀수'
print('[{}] 십의 자리 : {}!!, 일의 자리 : {}!!'.format(i, result10, result1))
i = int(input('정수 입력 : '))
sum = 0; oddSum =0; evenSum = 0; factorialResult = 1
for i in range (1, i+1):
sum += i
factorialResult *= i
if i %2 == 0:
evenSum += i
else:
oddSum += i
print('합 결과 : {}'.format(sum))
print('홀수 합 결과 : {}'.format(oddSum))
print('짝수 합 결과 : {}'.format(evenSum))
print('팩토리얼 결과 : {}'.format(format(factorialResult, ',')))
fNum = int(input('정수 입력 : '))
addSum = 0
for i in range(1, (fNum +1)):
addSum += i
addSumFormatted = format(addSum, ',')
print('합 결과: {}'.format(addSumFormatted))
oddSum = 0
for i in range(1, (fNum + 1)):
if i % 2 != 0:
oddSum += i
oddSumFormatted = format(oddSum, ',')
print('홀수 합 결과: {}'.format(oddSumFormatted))
evenSum = 0
for i in range(1, (fNum +1)):
if i % 2 == 0:
evenSum += i
evenSumFormatted = format(evenSum, ',')
print('짝수 합 결과: {}'.format(evenSumFormatted))
factorialResult = 1
for i in range(1, (fNum +1)):
factorialResult *= i
factorialResultFormatted = format(factorialResult, ',')
print('팩토리얼 결과: {}'.format(factorialResultFormatted))
# 1. 윗줄 첫 번째 모형
for i in range (1, 6):
for j in range(i):
print("*", end='')
print()
print('\n')
# 2. 윗줄 두 번째 모형
for i1 in range (1, 6):
for i2 in range(6 - i1 -1):
print(' ', end='')
for i3 in range(i1):
print('*', end='')
print()
print('\n')
# 3. 윗줄 세 번째 모형
for i in range (5, 0 ,-1):
for j in range(i):
print("*", end='')
print()
print('\n')
# 4. 윗줄 네 번째 모형
for i in range(5, 0 ,-1):
for j in range(5 - i):
print(' ', end='')
for j in range(i):
print('*', end='')
print()
print('\n')
# 5. 아랫줄 첫 번째 모형
for i in range (1, 10):
if i <= 5:
for j in range(i):
print("*", end='')
else:
for i in range(10 - i):
print('*', end='')
print()
print('\n')
# 6. 윗 줄 두 번째 모형
for i in range(1, 6):
for j in range(1, 6):
if j == i:
print('*', end='')
else:
print(' ', end='')
print()
print('\n')
# 7. 아랫줄 세 번째 모형
for i in range(1, 6):
for j in range(5, 0, -1):
if j == i:
print('*', end='')
else:
print(' ', end='')
print()
print('\n')
# 8. 아랫줄 네 번째 모형
for i in range(1, 6):
print(' ' * (5 - i) + '*' * (i * 2 -1))
for j in range(4, 0, -1):
print(' ' * (5 - j) + '*' * (j * 2 -1))
busA = 15
busB = 13
busC = 8
totalMin = 60 * 17
for i in range(totalMin + 1):
if (i < 20) or i > (totalMin - 60):
if i % busA == 0 and i % busB == 0:
print('busA와 busB 동시 정차!!', end='')
hour = 6 + i // 60
minute = i % 60
print('\t{}:{}'.format(hour, minute))
else:
if i % busA == 0 and i % busB == 0:
print('busA와 busB 동시 정차!!', end='')
hour = 6 + i // 60
minute = i % 60
print('\t{}:{}'.format(hour, minute))
elif i % busA == 0 and i % busC == 0:
print('busA와 busC 동시 정차!!', end='')
hour = 6 + i // 60
minute = i % 60
print('\t{}:{}'.format(hour, minute))
elif i % busB == 0 and i % busC == 0:
print('busB와 busC 동시 정차!!', end='')
hour = 6 + i // 60
minute = i % 60
print('\t{}:{}'.format(hour, minute))
gearACnt = int(input('Gear A 톱니수 입력 : '))
gearBCnt = int(input('Gear A 톱니수 입력 : '))
gearA = 0
gearB = 0
leastNum = 0
flag = True
while flag:
if gearA != 0:
if gearA != leastNum:
gearA += gearACnt
else:
flag = False
else:
gearA += gearACnt
if gearB != 0 and gearB % gearACnt == 0:
leastNum = gearB
else:
gearB += gearBCnt
print('최초 만나는 톱니수(최소공배수): {}톱니'.format(leastNum))
print('gearA 회전수: {}회전'.format(int(leastNum / gearACnt)))
print('gearB 회전수: {}회전'.format(int(leastNum / gearBCnt)))
lunarYr = int(input('연도 입력 : '))
if (lunarYr % 4 == 0 and lunarYr % 100 != 0) or (lunarYr % 400 == 0):
print('{}년 : 윤년!!'.format(lunarYr))
else:
print('{}년 : 평년!!'.format(lunarYr))
이상 데이터 취업 스쿨 파이썬 Chpt.2 기초문제풀이의 스터디노트이다.
여전히 스케줄 정상화 작업이 아직 진행 중인 상태이나, 그래도 velog 작성에 조금 익숙해지면서 작업 속도가 조금씩 빨라진다는 점을 위안 삼고 있다.
나중에 한꺼번에 모아 볼 생각으로 제출이 조금 늦어졌다는 부분이 매우 아쉽다고 느껴진다.
문제들은 대략적으로 풀 만 했으나, 후반부에서 많이 버벅이기 시작하였다.
강의를 수강하며 먼저 문제를 풀어보고, 만약 예시 답안과 많이 다르다면 두 답안을 같이 적어 놓았다.
예시 답안만큼 깔끔하게 코딩을 하는 것이 목표이나, 아직 많이 멀었다는 생각이 든다.
코드 작성 후 예시 답안과 비교하면서 어떤 부분에서 차이점이 보이는 지, 그리고 이를 통해 어떻게 코드 작성을 해야 하는지에 대하여 공부할 수 있는 기회가 되었다.
빠르게 진도를 따라잡는 것이 현재 목표이다.
이미지 출처: @waterglasstoon, 제로베이스 강의 일부