Question
in Python: Write a script that inputs a list of integers and passes it to the following functions, which you implement. Be sure to output
in Python:
Write a script that inputs a list of integers and passes it to the following functions, which you implement. Be sure to output the results of all function applications so we can test the correctness of your implementations.
a) A function that is passed any number of integer arguments and returns the largest among them. Use the arbitrary argument lists technique and unpack the input list to pass individual integers to the function where it is called.
b) A function that returns a list containing by default every 2nd element. This default can be overridden by passing a value for the keyword argument step. See the Step Argument slides.
c) A function that returns a list where each value is multiplied by n, where n is input (Use map, and prompt for the value for n before the function call.)
d) A function that returns the list of those elements that are multiples of n, where n is input (Use filter, and again prompt for n before the function call.)
e) A function that returns a list of pairs (2-element tuples), where the first element of a pair is the original number and the second is the sum of all previous numbers in the list (0 for the first list element). Consider using list comprehension. You can input an entire list (written with []) in one line from the terminal using eval(input(prompt)). For example,
>>> L = eval(input("Input a list: ")) Input a list: [1,2,3]
>>> L [1, 2, 3]
>>> type(L)
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