Question: 1.Recall that a sequence of numbers forms an arithmetic progression if the difference between every pair of consecutive numbers is the same. For example, [-5,
1.Recall that a sequence of numbers forms an arithmetic progression if the difference between every pair of consecutive numbers is the same. For example, [-5, -1, 3, 7, 11] form an arithmetic progression since the difference between every neighbor is 4. On the contrary, [5, 10, 15, 24, 29] is not an arithmetic progression since the difference between some consecutive pairs is 5 or 4. (USE PYTHON) A sequence that has exactly one number is considered arithmetic, too.
Write a function called arithmetic that takes as input a list of numbers and returns True if the numbers of the list form arithmetic progression. And False otherwise.
Testing: >>> arithmetic( [-5, -1, 3, 7, 11] ) True >>> arithmetic([0, -1, 3, 7, 11]) False >>> a = [5, 10, 15, 24, 29] >>> arithmetic(a) False >>> arithmetic(a[:3]) True
2.Now modify your method arithmetic slightly so that instead it tests if the numbers in the give lists are ordered for smallest to largest. Call the new function is_sorted
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
