Posted on 2009-02-22
I need to write a short code that uses the variables k and total to write a while loop that computes the sum of the squares of the first 50 counting numbers, and associates that value with total . so the code should associate 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 with total . This is the code i came up with, can anyone guide me as to what's wrong with it?
total=[1*1 + 2*2 + 3*3 +... + 49*49 + 50*50]
while k total:
2) i also need to write a code that uses a while loop that adds the integers from lo up through hi (inclusive), and associates the sum with result .
this is what i came up with: