LinkedIn Python Skill Assessment Quiz Answers

What does the built-in map() function do?

Latest Update on 25th January, 2022 by Certification Course Answers

What does the built-in map() function do?

  1.  It creates a path from multiple values in an iterable to a single value.
  2.  It applies a function to each item in an iterable and returns the value of that function.
  3.  It converts a complex value type into simpler value types.
  4.  It creates a mapping between two different elements of different iterables.

Correct Answer:

  •  It applies a function to each item in an iterable and returns the value of that function.

Explanation: – The synax for map() function is list(map(function,iterable). the simple area finder using map would be like this

import math
radius = [1,2,3]
area = list(map(lambda x: round(math.pi*(x**2), 2), radius))
area
>>> [3.14, 12.57, 28.27]

Latest Updates

No posts found in this category.