[Python] 조건문 연습2
Study Code/[Basic] Python2024. 5. 9. 00:39[Python] 조건문 연습2

난수를 이용해서 가위, 바위, 보 게임  import randomcomNum = random.randint(1, 3)userNum = int(input('1. 가위 | 2. 바위 | 3. 보 (숫자입력) >>> '))if ((comNum == 1 and userNum == 2) or (comNum == 2 and userNum == 3) or (comNum == 3 and userNum == 1)): print('컴퓨터는 {}번! '.format(comNum), end='') print('컴퓨터 패!')elif comNum == userNum: print('컴퓨터는 {}번! '.format(comNum), end='') print('무승부!!')else: ..

[Python] 조건문 연습1
Study Code/[Basic] Python2024. 5. 9. 00:38[Python] 조건문 연습1

국어, 영어, 수학, 과학, 국사 점수를 입력하면 총점을 비롯한 각종 데이터가 출력되는 프로그램     - 과목별 점수를 입력하면 총점, 평균, 편차를 출력         평균은 다음과 같다.         (국어: 85, 영어: 82, 수학: 89, 과학: 75, 국사: 94)     - 각종 편차 데이터는 막대그래프로 시각화  avgKor = 85; avgEng = 82; avgMath = 89; avgSciece = 75; avgHistory = 94sum = avgKor + avgEng + avgMath + avgSciece + avgHistoryavg = sum / 5kor = int(input('국어: '))eng = int(input('영어: '))math = int(input('수학: ')..

[Python] 연산자 연습3
Study Code/[Basic] Python2024. 5. 8. 00:17[Python] 연산자 연습3

금액, 이율, 거치기간을 입력하면 복리계산하는 복리계산기 프로그램  money = int(input('금액 입력: '))rate = float(input('이율 입력: '))term = int(input('기간 입력: '))targetMoney = moneyfor i in range(term): targetMoney += (targetMoney * rate * 0.01)targetMoneyFormated = format(int(targetMoney), ',') #format(숫자, ',') => 숫자를 천 단위로 쉼표(,)를 포함하여 포맷print('*' * 20)print('이율: {}원'.format(rate))print('원금: {:,}'.format(money)) # {:,} ..

[Python] 연산자 연습2
Study Code/[Basic] Python2024. 5. 8. 00:15[Python] 연산자 연습2

국어, 영어, 수학 점수 입력 후 총점, 평균, 최고점수 과목, 최저점수 과목 그리고 최고 점수와 최저 점수의 차이를 각각 출력  kor = int(input('국어 점수: '))maxScore, minScore = kor, kormaxObject, minObject = '국어', '국어'eng = int(input('영어 점수: '))if(eng > maxScore): maxScore = eng maxObject = '영어'else: minScore = eng minObject = '영어'math = int(input('수학 점수: '))if(math > maxScore): maxScore = math maxObject = '수학'else: minScore = ma..

[Python] 연산자 연습1
Study Code/[Basic] Python2024. 5. 8. 00:14[Python] 연산자 연습1

상품 가격과 지불 금액을 입력하면 거스름 돈을 계산하는 프로그램 단, 거스름 돈은 지폐와 동전의 개수를 최소로 하고, 1원단위 절사한다.  cnt50000, cnt10000, cnt5000, cnt1000, cnt500, cnt100, cnt10 = 0, 0, 0, 0, 0, 0, 0price = int(input('상품 가격 입력: '))pay = int(input('지불 금액: '))if pay > price: changeMoney = pay - price changeMoney = (changeMoney // 10) * 10 print('거스름 돈: {}(원단위 절사)'.format(changeMoney)) print('*' * 20)if changeMoney > 50000: ..

728x90
반응형
image