Python codes

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:
k=k**2
return 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:
while lo+hi=result
result=0
return result.sum

Student_101Asked:
Who is Participating?
 
Student_101Author Commented:
it's okay, i got it done:) thank you, and no i haven't had much success.
0
 
ramromconsultant Commented:
1 - This sounds like homework. We don't solve homework problems. We can help with specifics when you make an attempt and get stuck.

2 - "what's wrong with it" - why do you think something is wrong. It helps a lot if you tell us what you expect and what you get. If there is an exception, post the traceback.

3 - It appears that you don't understand Python syntax (or programming concepts in general?). Have you had success running any Python programs? Do you understand the syntax of while statements?

4 - Could you benefit from using for and range in problem 1?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.