Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the following template for EVERY function that you write. The docstring below should be placed inside of the function, just after the function signature.

image text in transcribed
image text in transcribed
Use the following template for EVERY function that you write. The docstring below should be placed inside of the function, just after the function signature. Purpose: Parameter(s): Return Value: Problem A. (10 points) List Difference Write a function list_difference(numlist1, numlist2) that takes in two lists as parameters. These lists contain numeric values and have the same length. Have the function return a new list that contains the difference between respective items in numlist1 and numlist2, without mutating either of the given lists. You are welcome to add an if __name _ = ' 'main _' block and test cases for this and all functions in this assignment but this is not required. Examples (text in bold is returned): alist =[5,6,7] blist =[2,2,2] list_difference(alist, blist) [3,4,5] alist [5,6,7] blist [2,2,2] list_difference ([0,1,1,2],[3,5,8,13]) Write a function larger_decrement(numlist, n ) that takes two parameters, a list of integers numlist, and an integer n. If the given list contains any number larger than n, then have the function mutate the list by decreasing the largest item in the list by 1 . If the list has two or more elements tied for the largest, only decrease the first occurrence. Then the function should return True. If the given list does not contain any number larger than n, it should return False. Hints: - The autograder will be expecting you to return a boolean value, make sure that you use the specific values True and False Hints: - You are not permitted to use built-in functions like max( or sorted() that trivialize the task of finding the largest element in the list. You are welcome to add an if __name_ == ' _ main__ block and test cases for this and all functions in this assignment but this is not required. Examples (text in bold is returned): alist =[5,20,74,81,0,81,3] > larger_decrement(alist, 50) True alist [5,20,74,80,0,81,3] blist =[1,3,5] larger_decrement(blist, 6)

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

Step: 3

blur-text-image

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

Students also viewed these Databases questions