Question

Write a Python function called FiveNumberSummary(myList) that takes as input a sorted list of numbers and...

Write a Python function called FiveNumberSummary(myList) that takes as input a sorted list of numbers and calculates and displays a five-number summary of the list. Given a list of numbers, a five-number summary of the numbers is defined to be the following: Minimum, First Quartile, Median, Third Quartile, Maximum. The first and third quartiles are simply the median of the first half of the numbers and the median of the second half of the numbers.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Source Code in Python:

import numpy as np
def FiveNumbersSummary(myList):
print("Minimum :",myList[0]) #since list is sorted, first element will be smallest
print("First Quartile :",np.percentile(myList,25)) #25th percentile is also 1st quartile, so we use numpy to calculate 25th percentile
print("Median :",np.percentile(myList,50)) #50th percentile is also median, so we use numpy to calculate median
print("Second Quartile :",np.percentile(myList,75)) #75th percentile is also 3rd quartile, so we use numpy to calculate 75th percentile
print("Maximum :",myList[len(myList)-1]) #since list is sorted, last element will be largest
FiveNumbersSummary([1,2,3,4,5,6,7,8]) #testing the function

Output: (refer to screenshot for indentations)

Add a comment
Know the answer?
Add Answer to:
Write a Python function called FiveNumberSummary(myList) that takes as input a sorted list of numbers and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider the list myList: myList = ["a", "America", "1", [5,3,9], "3", ["Mercy"]] #1 1) The Python...

    Consider the list myList: myList = ["a", "America", "1", [5,3,9], "3", ["Mercy"]] #1 1) The Python statement __________________ returns a #2 2) The Python statement __________________ returns America #3 3) The Python statement __________________ returns Ame #4 The type of the third element is _______. #6 The Python statement __________________ returns the following: ['Mercy'] #7 The python statement temp = _______ converts the third element to integer and assigns the result to temp. #8 Consider the fourth element of myList...

  • Write a python function alt which takes a list of strings myList as a parameter. alt...

    Write a python function alt which takes a list of strings myList as a parameter. alt then returns two strings s1 and s2 as a tuple (s1, s2). Here s1 is the concatenation of the strings in myList in even index positions, and s2 is the concatenation of the strings in myList in odd index positions. (List starts at index 0) For example, if myList = [‘My’, ‘kingdom’, ‘for’, ‘a’ , ‘horse’], then s1 = ‘Myforhorse’ and s2 = ‘kingdoma’.

  • Write a function called FirstElements for adding 100 random integers between 100 to 1000 to myList....

    Write a function called FirstElements for adding 100 random integers between 100 to 1000 to myList. using C program Project: List management Goa l: creating, updating and displaying a list using a menu. Instruction: Create an array called myList. Write a function called FirstElements for adding 100 random integers between 100 to 1000 to myList Initialize the first 100 elements of myList by calling the FirstElements function. Create a menu to display the following options and a number corresponding to...

  • Python Write a function called division that takes as input 2 numbers and divides them without...

    Python Write a function called division that takes as input 2 numbers and divides them without first checking what the inputs contain, returning the value of the division if it succeeds. If one of the inputs is not a number, print 'Cannot divide anything but numbers'. If denominator is 0, print 'Attempted to divide by zero'. If anything else causes the division to not work, print 'An unknown error occurred'. >>> division (6,2) >>> division(3, a) 'Cannot divide anything but...

  • Write a function abs_list_rec(values) that takes as input a list of numbers called values, and that...

    Write a function abs_list_rec(values) that takes as input a list of numbers called values, and that uses recursion to create and return a list containing the absolute values of the numbers in values. In other words, this function will do the same thing as the previous function, but it must use recursion instead of a list comprehension.

  • with python Write a function called linear_search which consumes a sorted list of integers and a...

    with python Write a function called linear_search which consumes a sorted list of integers and a number and linearly searches for the number in the list. Your function should return how many comparisons were made in order to find the element in the list. If the element is not in the list, your linear search should return -1 For example:

  • Write the definition of a function that takes as input the three numbers. The function returns...

    Write the definition of a function that takes as input the three numbers. The function returns turn if the first number to the power of the second number equals the third number otherwise it returns false. Assume that the three numbers are of type double. Use paw() function for the power.

  • Create a function that takes in an integer array called “input” and size. The function should...

    Create a function that takes in an integer array called “input” and size. The function should return a pointer to a dynamically created array the has two locations. The first is the minimum number in the input array and the second is the maximum number in input. Demonstrate your work by calling this function in main. The program should be c++

  • Write a function called ''minandmax'' . Function ''minandmax'' takes only one input argument that is a...

    Write a function called ''minandmax'' . Function ''minandmax'' takes only one input argument that is a matrix M . This matrix M can be any size (any number of columns and rows) with any random integer values . Function ''minandmax'' returns two output arguments. The first output argument is called ''difference_row'' that returns a row vector containing the absolute values of the difference between the maximum and minimum valued elements in each row. The second output argument is called ''difference_all''...

  • Problem 5 in python, write a function called sequencelength that accepts two input arguments: a list...

    Problem 5 in python, write a function called sequencelength that accepts two input arguments: a list of integers (called mylist here) and an integer (called x here). The function should return True if mylist contains an increasing sequence with a length of at least x values. Otherwise, the function should return False. An increasing sequence of numbers is one in which each number is larger than the one before it. For example, [4, 8, 13, 14, 21] is an increasing...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT