Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions