how to use sum in python

0 votes
is it possible to use sum function in python? can u explain with an example?
Mar 22, 2019 in Python by Waseem
• 4,540 points
1,032 views

2 answers to this question.

0 votes
num = [1,2,3,4]

s = sum(num)

print(s)
answered Mar 22, 2019 by Mohammad
• 3,230 points
0 votes

sum()=sum all item in a tuple 

syntax:

sum(iterble,start)

iterable required. The sequence to sum
start optional. A value that is added to the return value
 

a = (1, 2, 3, 4, 5)

x = sum(a, 7)

print(x)

output:22

if you are interested to learn to python than you can learn python because python is very easy language and less line of code as compare of other language . its syntax is very simple .

answered Mar 26, 2019 by rajesh
• 1,270 points

Related Questions In Python

0 votes
2 answers

How to use threading in Python?

 Thread is the smallest unit of processing that ...READ MORE

answered Apr 6, 2019 in Python by anonymous
1,351 views
0 votes
1 answer

How to use “raise” keyword in Python

You can use it to raise errors ...READ MORE

answered Jul 30, 2018 in Python by Priyaj
• 58,020 points
687 views
0 votes
1 answer

How to use string.replace() in python 3.x

replace() is a method of <class 'str'> ...READ MORE

answered Aug 3, 2018 in Python by Priyaj
• 58,020 points
1,140 views
+1 vote
2 answers

How to use the pass statement in Python

In Python programming, pass is a null statement. The ...READ MORE

answered Apr 5, 2019 in Python by anonymous
1,070 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,442 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,078 views
0 votes
1 answer

how to delete a file in python?

to delete a file import os os.remove('filename') this will delete ...READ MORE

answered Mar 18, 2019 in Python by Mohammad
• 3,230 points
897 views
0 votes
1 answer

how to execute python scripts in windows?

On Windows, To run a python module without typing "python", --> ...READ MORE

answered Mar 27, 2019 in Python by Mohammad
• 3,230 points
696 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP