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. a must be unchanged. Use:
Write and test the following function:
def max_diff(a): """ ------------------------------------------------------- Returns maximum absolute difference between adjacent values in a list. a must be unchanged. Use: md = max_diff(a) ------------------------------------------------------- Parameters: a - a list of values (list of int) Returns: md - the largest absolute difference between adjacent values in a (int) ------------------------------------------------------- """
Add this function to the PyDev module functions.py. Test it from t01.py
Examples:
>>> print(max_diff([])) 0 >>> 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
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