Ask Question

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

+3
Answers (1)
  1. 16 July, 17:41
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers