cos pro 파이썬 3급 예상문제.

2025. 6. 12. 14:33카테고리 없음

반응형

 

 

Q.1

사다리꼴 윗변, 아랫변, 높이를 입력 받아 넓이를 출력하는 프로그램 작성하기. 단, 소수점 첫째자리까지 반올림.


입력 예시

3
5
4


출력 예시
16.0

 

 

 

 

 

Q.1 -1

사다리꼴 윗변, 아랫변, 높이를 입력 받아 넓이를 출력하는 프로그램 작성하기. 단, 소수점 첫째자리까지 반올림.

입력 예시
3 5 4


출력 예시
16.0

 

 

 

 

Q.2

3과목의 점수를 받아 평균을 출력하는 프로그램을 작성하기. 단, 소수점 첫째자리까지 반올림.

입력예시
80
90
100


출력 예시
90.0

 

 

 

 

Q.2-1

3과목의 점수를 받아 평균을 출력하는 프로그램을 작성하기. 단, 소수점 첫째자리까지 반올림.

입력예시
80 90 100


출력 예시
90.0

 

 

 

 

Q.3

5명의 키를 입력받아 가장 큰 키와 가장 작은 키를 출력하는 프로그램 작성하기.

입력 예시
150
142
160
170
180


출력 예시
180 142

 

 

 

 

Q.3-1

5명의 키를 입력받아 가장 키가 작은 사람의 순번을 출력하는 프로그램 작성하기.

입력 예시
150
142
160
170
180


출력 예시
2

 

 

 

 

Q.4

정수 하나를 입력 받아 자릿수의 합을 출력하는 프로그램 작성하기.

입력 예시
12345


출력 예시
15

 

 

 

Q.5

영어 문자를 입력 받았을 때 대문자는 소문자로, 소문자는 대문자로 바꾸기.

입력 예시
Hello World


출력 예시
hELLO wORLD

 

 

 

Q. 5-1

영어 문자를 입력 받았을 때 각 단어의 첫글자를 대문자로 바꿔 출력하기.

입력 예시
hello world


출력 예시
Hello World

 

 

 

Q. 6

영어 단어들을 입력받고 각 단어들을 알파벳 오름차순으로 정렬하여 출력하기.

입력 예시
banana apple orange grape


출력 예시
apple banana grape orange

 

 

 

 

정답 예제 코드(아래 코드는 예시입니다. 이 방법만 사용되는 것은 아님.)

 

Q.1

a = int(input())
b = int(input())
c = int(input())


print(round((a + b) * c /2, 1))

 

Q.1-1

a, b, c = map(int, input().split())

print(round((a + b) * c /2, 1))

 

Q.2

a = int(input())
b = int(input())
c = int(input())


print(round((a + b + c)/3, 1))

 

 

Q.2-1

a, b, c = map(int, input().split())


print(round((a + b + c)/3, 1))

 

Q.3

 

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

arr = []

arr.extend([a, b, c, d, e])

print(max(arr), min(arr))

 

Q.3-1

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

arr = []

arr.extend([a, b, c, d, e])

print(arr.index(min(arr))+1)

 

Q.4

 

a = int(input())
hap = 0

while a > 0:
    hap += a % 10
    a //= 10

print(hap)

 

Q.5

a = input()

# 방법 1
print(a.swapcase())


# 방법 2
b = ''
for i in a:
    if i.isupper():
        b += i.lower()
    elif i.islower():
        b += i.upper()
    else:
        b +=i # 공백 또는 특수문자인 경우는 그대로 붙이기.
print(b)

 

Q.5-1

 

a = input()

print(a.title())

 

Q.6

# 방법 1.
a = input().split()
a.sort()

for i in a:
    print(i, end = ' ')



# 방법 2.
a = input().split()
a.sort()
print(' '.join(a))

 

 

 

728x90