Write a program which can map() to make a list whose elements are cube of elements in a given list
Answers
Answered by
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
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
Math,
6 months ago
Chemistry,
6 months ago
Computer Science,
11 months ago
English,
1 year ago
French,
1 year ago