Write a Python Program to Find Median
num = [2, 3, 5, 7, 10] n = len(num) num.sort() if n % 2 == 0: median1 = num[n//2] median2 = num[n//2 - 1] median = (median1 + median2)/2 else: median = num[n//2] print("Median: " + str(median))
Output:
Computer Science Tutorials
num = [2, 3, 5, 7, 10] n = len(num) num.sort() if n % 2 == 0: median1 = num[n//2] median2 = num[n//2 - 1] median = (median1 + median2)/2 else: median = num[n//2] print("Median: " + str(median))
Output: