Home  >  Article  >  Backend Development  >  How to sum in python

How to sum in python

coldplay.xixi
coldplay.xixiOriginal
2021-03-09 14:15:0788022browse

The method of summing in python: first define an array and input the integers to be summed; then use a for loop to save it in the array; then call the sum function to calculate the sum of all integers; finally output the calculated result The sum of all integers.

How to sum in python

The operating environment of this tutorial: Windows 7 system, python version 3.9, DELL G3 computer.

Method of summing in python:

1. First, define an array to save all the integers that are summed.

How to sum in python

#2. Enter the number of integers to be summed and save it in the variable n.

How to sum in python

#3. Use a for loop to control the input of all summed integers.

How to sum in python

#4. Enter all the summed integers and save them in the array.

How to sum in python

5. Output all the summed integers, as shown in the figure below.

How to sum in python

#6. Call the sum function to calculate the sum of all integers.

How to sum in python

#7. Finally, output the calculated sum of all integers.

How to sum in python

#8. Run the program and input the summed integers according to the number of integers entered, and the computer will calculate the sum of their integers.

How to sum in python

Related free learning recommendations: python video tutorial

The above is the detailed content of How to sum in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn