Answers for "python sum of numbers"

1

sum of number digits python

num = input("Enter your number: ")
result = 0
for n in str(num):
        result += int(n)
print("Result: ",result)

#code by fawlid
Posted by: Guest on November-09-2021
2

sum of any numbers in python

sum(list(map(int,input().split())))
Posted by: Guest on December-02-2020
0

sum of numbers in python

def sum_(n):
    if n == 0:
        return n
    else:
        prev_n = sum_(n - 1)
        result = prev_n + n
        return result


s = sum_(5)

print(s)

#Output:
# 15
Posted by: Guest on August-21-2021
0

python sum only numbers

def SumNum(mylist):
    the_sum = sum(filter(lambda i: isinstance(i, (int, long, float)), mylist))
    return the_sum
Posted by: Guest on August-20-2021

Python Answers by Framework

Browse Popular Code Answers by Language