Computer Science, asked by MarciaRoyal37, 11 months ago

Write a program which can map() to make a list whose elements are cube of elements in a given list

Answers

Answered by mishti53
6

Answer:

I have a list which I want to square each of them. this is what I have done def square(x): return x*x numbers = [1,2,3,4,5,6] squares = map(square, ...

Answered by Anonymous
0

Program which can map() to make a list whose elements are cube of elements in a given list is:

def cube(x):                               // Cube function created

       return x*x*x

numbers = [1,2,3,4,5,6]                // given list of numbers

cubes = map (cube, numbers)    // Cube function is mapped

print (str (cubes) )                       // prints the list of cube of elements in the  

                                                      number list.

Output is : [1  8  27  64  125  216 ]

Similar questions