Adding and removing columns
📖 Scenario: You work in a small grocery store. You have a table of products with their prices and quantities. You want to add a new column for the total value of each product (price times quantity). Later, you decide to remove the quantity column to keep the table simple.
🎯 Goal: Create a data table using a dictionary, add a new column for total value, then remove the quantity column, and finally display the updated table.
📋 What You'll Learn
Create a dictionary called
products with keys 'Name', 'Price', and 'Quantity' and the exact values specified.Create a new column
'TotalValue' by multiplying Price and Quantity for each product.Remove the
'Quantity' column from the dictionary.Print the final
products dictionary.💡 Why This Matters
🌍 Real World
Stores and businesses often keep product data in tables. Adding and removing columns helps update the data as needed.
💼 Career
Data analysts and scientists frequently manipulate tables by adding calculated columns and cleaning data by removing unnecessary columns.
Progress0 / 4 steps