> Program to calculate the value of the sum of squares defined as 1^2 + 2^2 + 3^2 + ... +n2. User supplies the value n.Usi

Program to calculate the value of the sum of squares defined as 1^2 + 2^2 + 3^2 + ... +n2. User supplies the value n.Usi

Posted at: 2014-12-18 
FOR Python

Try this Python 2 code:

n = int(input("Enter value for n: "))

sum = 0

i = 1

while i<=n:

.... sum += i * i

.... i += 1

print sum

# Note: I've used "...." to represent a tab character, which Y!Answers removes.

Well, I don't code, but know that the sum from i to n of i^2 = n(n+1)(2n+1)/6

Use the geometric series sum equation

FOR Python