5 Point Summary
5 Point Summary is a set of numbers that provide information on a sequence of given numbers. It gives the minimum number, the first quartile, the second quartile / the median, the third quartile and the maximum. These values can be used to draw a box and whisker plot. Finding the minimum and maximum is easy, and you can find the first and third quartile by finding the median of all the numbers, then finding the median of the minimum to the median, then the median to the maximum.
import math
def summary():
enter = " "
numbers = []
while enter != "":
enter = input("Enter your numbers(one by one): ")
if enter != "":
numbers.append(int(enter))
numbers.sort()
sum = 0
for x in numbers:
sum += x
print(numbers)
print("Sum:", sum)
average = sum/len(numbers)
print("Average:", average)
print("Minimum:", numbers[0])
median = mid(1, len(numbers))
print("Q1:", numbers[mid(1, median)])
print("Median/Q2:", numbers[median])
print("Q3:", numbers[mid(median, len(numbers))])
print("Maximum:", numbers[len(numbers)-1])
def mid(start, end):
middle = start + end
middle = middle/2
middle = math.ceil(middle) - 1
return middle
if __name__ == '__main__':
summary()
Comments
Post a Comment