Answer to Question #340524 in Python for Kaira

Question #340524

Write a while loop that calculates the sum of the cubes of numbers starting from 1 to 40 (inclusive). That is, the loop prints the foloowing value 1 + 23 +33 + ... +403. Make sure to define any variables you may need.


1
Expert's answer
2022-05-13T03:26:16-0400
s = 0
n = 1
while n <= 40:
	s += n**3
	n += 1
print(s)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS