How to use sum function in python to sum

王林
Release: 2020-05-09 10:17:30
Original
12859 people have browsed it

How to use sum function in python to sum

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

How to use sum function in python to sum

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

How to use sum function in python to sum

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

How to use sum function in python to sum

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

How to use sum function in python to sum

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

How to use sum function in python to sum

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

How to use sum function in python to sum

Finally, output the calculated sum of all integers.

How to use sum function in python to sum

The output results are as follows:

How to use sum function in python to sum

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!