Posted inPython

how to use sum function in python?

Today, We want to share with you sum function in python.In this post we will show you sum function in dictionary python, hear for sum of two numbers in python we will give you demo and example for implement.In this post, we will learn about fibonacci series in python with an example.

how to use sum formula in python

write a python function to sum all the numbers in a list?
Python sum() Function
The syntax of the sum() function is:

sum(iterable, start)

Example 1: Simple Example

a = (1, 2, 3, 4, 5)
x = sum(a, 7)
print(x)

Working of Python sum()

totalnos = [2.5, 3, 4, -5]

# start parameter is not provided
totalnos_sum = sum(totalnos)
print(totalnos_sum)

# start = 10
totalnos_sum = sum(totalnos, 10)
print(totalnos_sum)

Example 3: Find the sum of all the numbers in a list

def sum(totalnos):
    total = 0
    for x in totalnos:
        total += x
    return total
print(sum((9, 6, 5, 0, 4)))

I hope you get an idea about python sum list of lists.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype