Function arguments
📖 Scenario: You are helping a small bakery calculate the total cost of different types of cakes ordered by customers. Each cake has a price and a quantity ordered.
🎯 Goal: Build a function that takes the price and quantity of a cake as arguments and returns the total cost. Then use this function to calculate the total cost for a specific order.
📋 What You'll Learn
Create a function called
calculate_cost that takes two arguments: price and quantity.Inside the function, multiply
price by quantity and return the result.Call the function with
price = 15 and quantity = 3.Print the result of the function call.
💡 Why This Matters
🌍 Real World
Calculating costs based on quantity and price is common in shops, restaurants, and online stores.
💼 Career
Understanding how to write functions with arguments is essential for automating calculations and processing data efficiently in many programming jobs.
Progress0 / 4 steps