쉽고 깔끔하게
[프로그래머스/python3] Level 1 평균 구하기 문제풀이 본문
728x90
반응형

문제
programmers.co.kr/learn/courses/30/lessons/12944
코딩테스트 연습 - 평균 구하기
정수를 담고 있는 배열 arr의 평균값을 return하는 함수, solution을 완성해보세요. 제한사항 arr은 길이 1 이상, 100 이하인 배열입니다. arr의 원소는 -10,000 이상 10,000 이하인 정수입니다. 입출력 예 arr
programmers.co.kr
정수를 담고 있는 배열 arr의 평균값을 return 하는 함수, solution을 완성해보세요.
<정답>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(arr): | |
return sum(arr) / len(arr) |
※ 평균을 구하기 위해서 배열 arr의 모든 값의 합과 길이를 나누는 것이 핵심!
728x90
반응형
'Algorithm > Programmers' 카테고리의 다른 글
[프로그래머스/python3] Level 1 서울에서 김서방 찾기 문제풀이 (0) | 2021.01.18 |
---|---|
[프로그래머스/python3] Level 1 가운데 글자 가져오기 문제풀이 (0) | 2021.01.18 |
[프로그래머스/python3] Level 1 짝수와 홀수 문제풀이 (0) | 2021.01.18 |
[프로그래머스 코딩 테스트 연습 SQL/MySQL] IS NULL #3 NULL 처리하기 문제풀이 (0) | 2021.01.05 |
[프로그래머스 코딩 테스트 연습 SQL/MySQL] IS NULL #2 이름이 있는 동물의 아이디 문제풀이 (0) | 2021.01.05 |