Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions