Question: Write a function called get_median that accepts a list of numbers and returns the median value of the list. The median value is the middle

Write a function called get_median that accepts a list of numbers and returns the median value of the list. The median value is the middle value in an ordered sequence of numbers. If there are two values in the middle (a, and b), then the median is the value halfway between them (e.g., (a + b) / 2. The list passed as a parameter should not be altered. If the list contains any negative numbers then generate a ValueError exception with the message "Negative numbers are invalid"

For example:

TestResult
print(get_median([5, 1, 4, 2, 3]))
3

and

A Person class should store the name and phone number for a person.

The following code shows how the Person class is used:

name = 'Ann' phone = 67362123 p = Person(name, phone) p.update_phone(123456) print(p)

This code would produce the output:

Contact Ann at 123456

Write the constructor, the update_phone method, and the __str__ method for the Person class. Submit the entire class.

and

Given a dictionary representing a frequency table of words, write a function called get_ordered_words that will accept the dictionary as a parameter and return a list of the words, ordered by the number of times they appeared (most frequent first), and then alphabetically if they appeared the same number of times.

For example:

TestResult
freq = {'e': 2, 'c': 3, 'a': 2, 'b': 3, 'd': 2, 'f': 1} print(get_ordered_words(freq))
['b', 'c', 'a', 'd', 'e', 'f']

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sure here are the implementations of the functions you described getmedian Heres a function that calculates the median of a list of numbers python def ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!