<span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">def test(*args):</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">...._len=len(args)</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">...._sum=0</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">....for i in range(_len):</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">........_sum=_sum+args[i]</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">....return _sum/_len</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">위함수는 list안의 평균을 return 하는 함수 입니다.</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">a=[2,2,3]</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">print(test(*a))</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">요렇게 하면 2,2,3의 평균이 return 이 되거든요</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">m=[[1,1,1],[2,2,2],[3,3,3],[4,4,4]]</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">이런 list 가 있을때</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">print(list(map(sum,m)))</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">--> [3, 6, 9, 13]</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">print(list(map(min,m)))</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">--> [1, 2, 3, 4]</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">이렇게 map 함수를 써서 2차원 list안에 있는 list들의 min/max/sum등을 구할수 가 있는데..</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">평균을 구하는것을 만들고 싶어서 위 함수를 만든것입니다.</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">print(list(map(test,*m)))</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">기대 값은 [1, 2, 3, 4] 가 나왔으면 했는데..</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">[2.5, 2.5, 2.5] 로 1,2,3,4의 평균값이 나와서요.</span><br style="font-family:'돋움', Dotum, AppleGothic, sans-serif;"><span style="font-family:'돋움', Dotum, AppleGothic, sans-serif;">어디가 잘못된건지.. 조언좀 부탁드립니다.</span>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.