Using map() for Element-wise Mapping in Data Science
📖 Scenario: You work in a small grocery store. You have a list of prices for some fruits. You want to apply a discount to each price to prepare for a sale.
🎯 Goal: Learn how to use the map() function to apply a discount to each price in a list.
📋 What You'll Learn
Create a list of fruit prices
Create a discount rate variable
Use
map() with a function to apply the discount to each pricePrint the discounted prices as a list
💡 Why This Matters
🌍 Real World
Applying discounts or taxes to prices is common in retail and e-commerce. Using <code>map()</code> helps automate this process efficiently.
💼 Career
Data analysts and scientists often need to transform data element-wise. Knowing how to use <code>map()</code> is a basic but important skill.
Progress0 / 4 steps