# # Domaci ukol 04 - funkce weighted_mean # Homework 04 # def weighted_mean(list, weight): """ 2 body # 2 points Funkce weighted_mean pocita vazeny prumer ze zadaneho listu, tak ze prvni prvek je do prumeru zapocitan s vahou weight. Pro list [1, 2, 3] a weight 2 to znamena, ze 1 je zapocitana dvakrat a pocet prvku je tedy 4. Function weighted_mean calculate weighted mean from list, that first item from list is weighted by parameter weight. For list [1, 2, 3] and weight 2 it means, that 1 is counted two times and length of list is 4. >>> weighted_mean([1, 2, 3], 2) 1.75 >>> weighted_mean([2.5, 6.6, 1.4], 4) 3.0 """ return 0.0 if weighted_mean([1, 2, 3], 2) == 1.75 and weighted_mean([2.5, 6.6, 1.4], 4) == 3.0: print("{:37} {}".format("Function #4 (weighted_mean):", "ok *")) else: print("{:37} {}".format("Function #4 (weighted_mean):", "ko -")) #import doctest #doctest.testmod()