
Coding test/Python 기초문제
![[%, // 연산자] 빵과 우유 배분하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FccDFT9%2FbtrzzqqB6IZ%2FHkR49oCaiKN5B4qS8vTVd0%2Fimg.png)
[%, // 연산자] 빵과 우유 배분하기
1. 문제 %과 //를 이용하여 빵과 우유 배분 2. 사용함수 a // b : a를 b로 나눈 몫 a % b : a를 b로 나눈 나머지 3. 실행 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 bread = 197 milk = 152 student = int(input("학생 수:")) if bread >= student: breadPerStudent = bread // student restBread = bread % student if milk >= student: milkPerStudent = milk // student restMilk = milk % student print('학생 한 명이 갖게되는 빵 개수: {}'.form..
![[for 반복문] 복리 계산기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbHn9KY%2FbtrzyYue5mm%2FguQPISkr63HU3DWPJSw6o0%2Fimg.png)
[for 반복문] 복리 계산기
1. 문제 for 반복문을 이용한 복리 계산기 2. 사용함수 3. 실행 price = int(input('금액 입력:')) percent = float(input('이율 입력:')) year = int(input('기간 입력:')) targetMoney = price for i in range(year): targetMoney = targetMoney + targetMoney * percent * 0.01 print('-'*30) print('이율:{}%'.format(percent)) print('원금:{}원'.format(format(price, ','))) print('{}년 후 금액: {}원'.format(year, format(int(targetMoney), ','))) print('-'*30)..
![[if/elif 조건문] 성적표 출력하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FXGoY1%2Fbtrzzo7iG4j%2FhVGn65j2OoaAj8r4nwt9w1%2Fimg.png)
[if/elif 조건문] 성적표 출력하기
1. 문제 if ~ elif 조건문을 이용하여 국어, 수학, 영어 점수 성적표 출력 1) 최고점, 최저점, 차이 구하기 2) 평균, 총점 구하기 3) 점수가 중복일 경우도 반영하기 2. 사용함수 .isdigit() : 숫자면 True, 아니면 False max(a, b, c) : a, b, c 중 가장 큰 수 출력 min(a, b, c) : a, b, c 중 가장 작은 수 출력 3. 실행 kor = input('국어 점수 입력:') if kor.isdigit(): eng = input('영어 점수 입력:') kor = int(kor) if eng.isdigit(): eng = int(eng) math = input('수학 점수 입력:') if math.isdigit(): math = int(math) s..
![[while 반복문] 거스름돈 계산기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fc9v5Bc%2FbtrzxaB7rCR%2FPiMH7qFOHtojZeICNq4GB0%2Fimg.png)
[while 반복문] 거스름돈 계산기
1. 문제 상품 가격을 입력하고 지불금액을 입력하면 거스름돈 출력. 2. 사용함수 .isdigit() : 숫자면 True, 아니면 False flag = True -> break를 하지않는 이상 영원히 반복 3. 실행 price = input('상품가격 입력:') if price.isdigit(): money = input('지불금액 입력:') if money.isdigit(): restMoney = (int(money) - int(price))//10 * 10 print('거스름돈:', restMoney, "(원단위 절사)") flag = True cnt50000 = 0 cnt10000 = 0 cnt5000 = 0 cnt1000 = 0 cnt500 = 0 cnt100 = 0 cnt50 = 0 cnt10..
![[if~else 조건문] 100살 계산기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdxzhJ4%2FbtrzzpSD2EY%2FIj5hI7fSfyPkE4cDk1rZzk%2Fimg.png)
[if~else 조건문] 100살 계산기
1. 문제 나이를 입력하면 몇년 후에 내가 100살인지 계산. 2. 사용함수 .isdigit() : 숫자면 True, 아니면 False datetime.datetime.today() : 오늘 날짜 출력 today.year : 해당 연도 출력 3. 실행 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import datetime today = datetime.datetime.today() age = input('나이를 입력하시오:') if age.isdigit(): myHundred = 100 - int(age) afterYear = today.year + myHundred else: print('잘못입력했음') print('{}년({}년후)에 당신의 나이는 100살입니다.'.format(aft..