Given that n refers to a positive integer, use a while loop to compute the sum of the cubes of the first n counting numbers, and assign this value to total. In other words, total should be assigned: 1 * 1 * 1 + 2 * 2 * 2 + … n * n * n Use no variables other than n, k, and total.
Python 4
Given that n refers to a positive integer, use a while loop to compute the sum of the cubes of the first n counting numbers, and assign this value to total. In other words, total should be assigned: 1 * 1 * 1 + 2 * 2 * 2 + … n * n * n Use no variables other than n, k, and total.

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images

python programming please help me fix the code
Question:
Given that n refers to a positive integer, use a while loop to compute the sum of the cubes of the first n counting numbers, and assign this value to total. In other words, total should be assigned: 1 * 1 * 1 + 2 * 2 * 2 + … n * n * n Use no variables other than n, k, and total.
I answered :
#cube value
n=5
#additional variables
total = 0
k=0;
# while loop
while(n<=5 and n>0):
k+=1
total = total + (k*k*k)
n-=1
#display total
print (total)
comments :Unexpected identifiers: additional, and, cube, display, loop, print, value, variables I haven't yet seen a correct solution that uses: ; I haven't yet seen a correct solution that uses: and I haven't yet seen a correct solution that uses: print Solutions with your approach don't usually use: -= Solutions with your approach don't usually use: > and then it says logic errors








