First, define an array to save all the integers that are summed.
#Enter the number of integers to be summed and save it in the variable n.
Use a for loop to control the input of all summed integers.
Enter all the summed integers and save them in the array.
Output all the summed integers, as shown in the figure below.
Call the sum function to calculate the sum of all integers.
Finally, output the calculated sum of all integers.
The output results are as follows:
Recommended tutorial:python tutorial
The above is the detailed content of How to use sum function in python to sum. For more information, please follow other related articles on the PHP Chinese website!