본문 바로가기
프로그래밍/파이썬

클래스놈 파이썬 문제 풀이

by 노마드데이터랩 2023. 3. 31.
728x90
반응형

어떤분이 클래스놈 사이트 예제 문제풀이 요청하셔서 답변드립니다.

문제

1. 세 과목 성적의 합계와 평균을 출력하시오.
2. 주소록(학교이름, 학과, 이름, 연락처)를 변수에 저장하고 출력하시오.
3. 초 단위 시간을 입력 받아서 몇 시간, 몇 분, 몇 초인지를 출력하는 프로그램을 작성하시오.
4. 파이썬 과목은 성적반영비율이 아래와 같다.(출석: 10%, 과제: 30%, 중간: 30%, 기말: 30%) 항목 점수를 가정하여 입력하고 전체 총점을 출력하는 프로그램을 작성하시오.
5. 상점의 매출액을 계산하는 프로그램을 작성하시오. (상품은 3개가 있다고 가정한다.)
6. 정수를 입력받아 각 자리수를 분리하는 프로그램을 코딩하시오. 예)835 -> 백의 자리: 8, 십의 자리:3, 일의 자리:5

1번 문제 답

score1 = int(input("첫 번째 과목의 점수를 입력하세요: "))
score2 = int(input("두 번째 과목의 점수를 입력하세요: "))
score3 = int(input("세 번째 과목의 점수를 입력하세요: "))

total_score = score1 + score2 + score3
avg_score = total_score / 3

print("성적 합계:", total_score)
print("성적 평균:", avg_score)


2번 문제 답

school = "하버드대학교"
department = "컴퓨터 사이언스"
name = "홍길동"
phone = "010-1234-5678"

print("학교 이름:", school)
print("학과:", department)
print("이름:", name)
print("연락처:", phone)


3번 문제 답

time_in_sec = int(input("초 단위 시간을 입력하세요: "))

hours = time_in_sec // 3600
minutes = (time_in_sec % 3600) // 60
seconds = time_in_sec % 60

print(hours, "시간", minutes, "분", seconds, "초")

 

4번 문제 답

attendance = int(input("출석 점수를 입력하세요: "))
homework = int(input("과제 점수를 입력하세요: "))
midterm = int(input("중간고사 점수를 입력하세요: "))
final = int(input("기말고사 점수를 입력하세요: "))

attendance_weight = 0.1
homework_weight = 0.3
midterm_weight = 0.3
final_weight = 0.3

attendance_score = attendance * attendance_weight
homework_score = homework * homework_weight
midterm_score = midterm * midterm_weight
final_score = final * final_weight

total_score = attendance_score + homework_score + midterm_score + final_score

print("출석 점수:", attendance_score)
print("과제 점수:", homework_score)
print("중간고사 점수:", midterm_score)
print("기말고사 점수:", final_score)
print("전체 총점:", total_score)



5번 문제 답

product1_price = int(input("상품 1의 가격을 입력하세요: "))
product1_sales = int(input("상품 1의 판매량을 입력하세요: "))
product2_price = int(input("상품 2의 가격을 입력하세요: "))
product2_sales = int(input("상품 2의 판매량을 입력하세요: "))
product3_price = int(input("상품 3의 가격을 입력하세요: "))
product3_sales = int(input("상품 3의 판매량을 입력하세요: "))

total_sales = product1_price * product1_sales + \
              product2_price * product2_sales + \
              product3_price * product3_sales

print("총 매출액은", total_sales, "원입니다.")

 

6번 문제 답

num = int(input("정수를 입력하세요: "))

hundreds = num // 100
tens = (num % 100) // 10
ones = num % 10

print("백의 자리:", hundreds)
print("십의 자리:", tens)
print("일의 자리:", ones)

 

728x90
반응형

댓글