Ask Question
9 September, 14:29

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

+5
Answers (1)
  1. 9 September, 16:23
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers