👻 *Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!*

*The Python sum () function calculates the total of all numeric values ‚Äã‚Äãin an iterable. sum () works with both integers and floating point numbers. The sum () function has an optional parameter to add a number to the total.*

Computing the sum of a list is a common operation in Python. For example, suppose you are the owner of a cafe and want to know the total value of all sales made in the past month. You can use the *sum ()* function to perform this calculation.

In Python code, the *sum ()* function can be used to calculate the sum of all values ‚Äã‚Äãin an iterable object. This method is useful when you need the total value of a list of items, which is common in many math calculations.

In this tutorial, we’ll see how to use the Python *sum () * method. We will look at some examples to show how this method works in a real program.

## Python Sum Syntax

The Python sum () function sums all the numeric values ‚Äã‚Äãin an iterable, such as a list, and returns the total of those values. sum () calculates the total of floating point numbers and integers.

For example, you can use the *sum ()* method to calculate the total price of products for a customer store in a store.

Here is the syntax of the Python *sum ()* method:

The *sum ()* function accepts two parameters: