Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
744 B
3
Indexable
Never
def median(numbers):
    
    numbers.sort()
    length = len(numbers)
    if length % 2 == 0:
        return (numbers[length // 2 - 1] + numbers[length // 2]) / 2
    else:
        return numbers[length // 2]
numbers = [1, 6, 6, 9, 6, 3, 8]
median_num = median(numbers)
print("Median:", median_num)

def mean(numbers):
   
    return sum(numbers) / len(numbers)
numbers = [1, 8, 5, 2, 6, 3, 9]
mean_num = mean(numbers)
print("Mean:", mean_num)

def mode(numbers):

    from collections import Counter
    count = Counter(numbers)
    max_count = max(count.values())
    return [num for num, freq in count.items() if freq == max_count]
numbers = [1, 2, 5, 7, 6, 3, 9]
mode_num = mode(numbers)
print("Mode:", mode_num)
Leave a Comment