0
0
Pythonprogramming~10 mins

sum() function in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Using the sum() Function in Python
๐Ÿ“– Scenario: You are helping a small shop owner who wants to quickly add up the prices of items sold in a day.
๐ŸŽฏ Goal: Build a simple program that uses the sum() function to add all the prices in a list and show the total sales.
๐Ÿ“‹ What You'll Learn
Create a list of item prices
Create a variable to hold the total sum
Use the sum() function to add all prices
Print the total sum
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Adding prices or scores quickly is common in shops, schools, and many daily tasks.
๐Ÿ’ผ Career
Knowing how to sum values helps in data analysis, finance, and programming jobs where totals are needed.
Progress0 / 4 steps
1
Create a list of item prices
Create a list called prices with these exact values: 10.5, 23.99, 5.0, 12.75, and 7.25.
Python
Need a hint?

Use square brackets [] to create a list and separate values with commas.

2
Create a variable to hold the total sum
Create a variable called total and set it to 0.
Python
Need a hint?

Just write total = 0 to start with zero.

3
Use the sum() function to add all prices
Use the sum() function on the prices list and assign the result to the variable total.
Python
Need a hint?

Use sum(prices) to add all numbers in the list.

4
Print the total sum
Write a print() statement to display the text Total sales: followed by the value of total.
Python
Need a hint?

Use an f-string like print(f"Total sales: {total}") to show the result.