Write a program that has two functions: the main function and a function, called sumOfSquared(n), that takes an integer number (read in the main function uisng input) and calculates the total sum of squares of all numbers from 1 to a given number. Then, it returns the result to the main function. Finally, the result should be printed.
def sumOfSquared(n):
sumResult=0
for i in range(1,n+1):
sumResult+=i*i
return sumResult
n=int(input("Enter n: "))
print(f"The total sum of squares of all numbers from 1 to {n}: {sumOfSquared(n)}")
Comments
Leave a comment