Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write and test the following function: def max_diff(a): ------------------------------------------------------- Returns maximum absolute difference between adjacent values in a list. Use: md = max_diff(a) -------------------------------------------------------
Write and test the following function:
def max_diff(a): """ ------------------------------------------------------- Returns maximum absolute difference between adjacent values in a list. Use: md = max_diff(a) ------------------------------------------------------- Preconditions: a - a list of values (list of float) Postconditions: returns md - the largest absolute difference between adjacent values in a (float) ------------------------------------------------------- """
Add this function to the PyDev module asgn01.py. Test it from q7.py.
Examples:
>>> print(max_diff([0, 0, 0, 0])) 0 >>> print(max_diff([0, 1, 2, 3])) 1 >>> print(max_diff([5, 10, 20, 40])) 20 >>> print(max_diff([-5, 5, 7, 11])) 10
Also side note, 1 function and 1 main module (your importing the function)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started