Ask Question
19 September, 12:08

Write a python program called loop that computes and prints the sum of numbers from 1 to 10

+3
Answers (1)
  1. 19 September, 12:42
    0
    Here is code in Python.

    # variable to store sum of numbers from 1 to 10

    sum=0

    for i in range (1,11):

    #calculating the sum

    sum+=i

    #printing the sum

    print ("sum of numbers from 1 to 10 is:")

    print (sum)

    Explanation:

    Declare a variable "sum" to store the sum of all the numbers from 1 to 10.

    In the for loop i will iterate from 1 to 10 only and each value of i is added to

    "sum". then it will print the sum of all the number.

    Output:

    sum of numbers from 1 to 10 is:

    55
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a python program called loop that computes and prints the sum of numbers from 1 to 10 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers