What Is SUM Function and How To Use In Python, Excel, and Mathlab?


SUM is the short form of the summation which is a mathematical operation. SUM is a very popular term used in computing, programming, scripting to describe the mathematical summation operation.

Usage Of SUM

Sum is a mathematical function which can summation of two or more numbers. This means at least two number or parameters to require for the summation. More than two numbers also used and expressed like below as mathematical way.

2 + 3 = 5

2 + 3 + 4 = 9

2 + 3 + 4 + 5 = 14

Python Sum Function Examples

Python programming language provides the sum() function for the summation operations. Sum function can accept a list type of numbers for the summation. The summation result will be returned by the sum function. The parameters should be integer or floating-point. The list type can be a list or tuple. Also a staring number can be added after the list type for the summation. This starting number is optional parameter.

sum(LIST,START_NUMBER)
result = sum((1,2,3))
print(result)
# The output will be 6


result = sum([1,2,3,4,5])
print(result)
# The output will be15


result = sum([1,2,3,4,5],10)
print(result)
# The output will be25
Python Sum Function Examples

Excel Sum Function Examples

Ms Office Suite member Excel also provides the SUM function where given cell values can be summed. The cell values should be numerical values and if the values are string type the SUM function will throw error. The cell name or range is provided to the SUM function where multiple cell ranges can be also provided

SUM(CELL_RANGE1,CELL_RANGE2,…)

Excel Sum Function Examples

Matlab Sum Function Example

Matlab is another application that provides the sum() function for different ways for summation. Matlab sum function can be used for different parameter types like Vector, Matrix Columns, Rows, Array Slices, 3-d Aray, Integers, etc. Below we will make some sum() function examples with different data types.

LEARN MORE  Linux Bash Operators Like Assignment, Plus, Calculation
Sum of Vector Elements
Sum of Matrix Columns
Sum of Matrix Rows
Sum of 32-bit Integers

Leave a Comment