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