two sum in python code example
Example 1: sum of 2 numbers in python
a = int(input("Enter first number:"))
b = int(input("Enter second number:"))
sum = a+b
print(sum)
Example 2: sum() python
numbers = [2.5, 3, 4, -5]
# start parameter is not provided
numbers_sum = sum(numbers)
print(numbers_sum)
# output = 4.5
# start = 10
numbers_sum = sum(numbers, 10)
print(numbers_sum)
# output = 14.5
Example 3: how to return the sum of two numbers python
def add(a, b):
return a + b