Answer to Question #296292 in Python for Arab

Question #296292

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.  


1
Expert's answer
2022-02-10T13:32:16-0500
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)}")

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