Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is my code, but I want you to check these code. And I do not know number 4 and 6 right now. def cube(T):

This is my code, but I want you to check these code. And I do not know number 4 and 6 right now.

def cube(T): #1 return(T*T*T) a = list(range(1, 11)) print(a) m = map(cube, a) print(m) print()

def divisible_3(T): #2 if(T % 3 == 0): return T a = list(range(1, 11)) print(a) f1 = map(divisible_3, a) print(f1) print()

def cube(T): #3 return(T*T*T) a = list(range(1, 11)) print(a) cube = [(T*T*T) for T in a] print(cube) print()

a = list(range(1, 11)) #5 print(a) divisible_3 = [(if(T % 2 == 0): return T) for T in a] print(div_3) print()

a = list(range(1, 11)) #7 print(a) divisible_3 = [(if(T % 2 == 0): return T) for T in a] print(divisible_3) print()

def findMin(x, y): #8 if (x < y) in return x else return y

From here, questions.

Let a be the list of values produced by list(range(1, 11)).

[1 point] Using the map function and a lambda argument, write an expression that produces a list of the cubes of the values in a. Assign the result to a variable called m and print m.

[1 point] Using the filter function and a lambda argument, write an expression that produces a list of the values in a that are divisible by 3. Assign the result to a variable called f1 and print f1.

[1 point] Using the reduce function and a lambda argument, write an expression that returns the result of concatenating all the digits in a. Assign the result to a variable called r1 and print r1. The output from this step is the string '12345678910'

[1 point] Use a list comprehension to produce the same list as in question 1 (i.e., the new list will contain the cubes of the values in a).

[1 point] Use a list comprehension to produce the same list as in question 2.

[1 point] Use a list comprehension to produce a list containing the cubes of the values in a that are divisible by 3. The output from this step is the list [27, 216, 729]

[2 points] Write a function named evenFilter that takes as an argument a dictionary of elements indexed by integer keys. Using only a list comprehension, return the values of the elements associated with the keys that are evenly divisible by 2. For example, >>> data = {1: "one", 3: "three", 4: "four", 5: "five", 8: "eight", 10: "ten"} >>> print(evenFilter(data)) ['four', 'eight', 'ten']

[2 points] Write a function called findMin(x, y) that uses the ternary operator (i.e, conditional expression) to find and return the minimum of its two arguments. Assume that x and y are numbers. Write code to test this function.

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions

Question

On average, what is the largest revenue component measure?

Answered: 1 week ago

Question

What is managements expected profit margin for each product?

Answered: 1 week ago