Programming/백준

[백준] 10817 - 세 수 (파이썬)

pental 2020. 4. 5. 12:57

먼저 문제는 위와 같다.

파이썬에는 내장함수로 max()와 min()이 존재하는데 왜 medium은 없는걸까?

사실 있다.

import statistics
a = list(input().split())

result = 0
A = int(a[0])
B = int(a[1])
C = int(a[2])

print(statistics.median([A,B,C]))
import statistics
print(statistics.median([10, 20, 30]))
>> 20

statistics 모듈을 사용하면 median이라는 함수를 사용할수 있다.

참고 : https://woogyun.tistory.com/522

 

Python에서 중간값(median) 구하기

중간값이란 여러 값을 오름차순이나 내림차순으로 늘어놓았을 때, 맨 가운데 있는 값을 말한다. 값들의 개수가 짝수라면 가운데 두 값의 산술평균을 중간값으로 정한다. Python 3.5에는 statistics라는 모듈이 있..

woogyun.tistory.com