Question: Python comprehension problems Write each of the following three procedures using a comprehension: Problem 1.7.1: my filter(L, num) input: list of numbers and a positive

Python comprehension problems Write each of the following three procedures using a comprehension:

Problem 1.7.1: my filter(L, num) input: list of numbers and a positive integer. output: list of numbers not containing a multiple of num. example: given list = [1,2,4,5,7] and num = 2, return [1,5,7].

Problem 1.7.2: my lists(L) input: list L of non-negative integers. output: a list of lists: for every element x in L create a list containing 1, 2,...,x. example: given [1,2,4] return [[1],[1,2],[1,2,3,4]]. example: given [0] return [[]].

Problem 1.7.3: my function composition(f,g) input: two functions f and g, represented as dictionaries, such that g f exists. output: dictionary that represents the function g f. example: given f = {0:a, 1:b} and g = {a:apple, b:banana}, return {0:apple, 1:banana}.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!