Ask Question
12 March, 09:01

Assume there is a variable, h already associated with a positive integer value. write the code necessary to compute the sum of the first h perfect squares, starting with 1. (a perfect square is an integer like 9, 16, 25, 36 that is equal to the square of another integer (in this case 3*3, 4*4, 5*5, 6*6 respectively).) associate the sum you compute with the variable q. for example, if h is 4, you would assign 30 to q because the first 4 perfect squares (starting with 1) are: 1, 4, 9, 16 and 30==1+4+9+16. submit

+3
Answers (1)
  1. 12 March, 09:28
    0
    Let q be the variable to be computed associated with h. the code is given below as

    q=0 / initial value assigned is 0

    for i in range (1, h+1) : / for loop is formatted with range 1 t0 h+1

    q+=i**2 / sum q is computed as square of i
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assume there is a variable, h already associated with a positive integer value. write the code necessary to compute the sum of the first h ...” in 📗 Mathematics 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