Robotics & Artificial Intelligence
Write a program to find and display the sum of any ten natural numbers.
Python Control Flow
3 Likes
Answer
s = 0
print("Enter any ten natural numbers:")
for i in range(10):
n = int(input())
s = s + n
print("Sum of ten natural numbers =", s)Output
Enter any ten natural numbers:
5
4
6
7
3
2
9
8
10
23
Sum of ten natural numbers = 77
Answered By
3 Likes
Related Questions
Write Python code to find the sum of the given series:
1 + (1*2) + (1*2*3) + …………… + (1*2*3*……………*n)
Write Python code to find the sum of the given series:
S = 1! + 2! + 3! + 4! + …………… + n!
[Hint: Factorial of 5! = 5*4*3*2*1]
Write a program to input any 20 numbers (including positive and negative). The program displays the sum of all positive numbers and negative numbers separately.
Write a program to enter a number and display the sum of its digits.
Sample Input: 642
Output: 12 (6+4+2 = 12)