Python program to find squares of the summation of n numbers

Hello everyone, welcome to In this article we will going to discuss about Python program to find squares of the summation of n numbers.

Here’s an example of a Python program that calculates the square of the summation of a given number of numbers:

Code for python program to find squares of the summation of n numbers

def summation_square(n):
    sum = 0
    for i in range(1, n+1):
        num = int(input("Enter a number: "))
        sum += num
    return sum**2

n = int(input("Enter the number of elements: "))
print("Square of the summation of", n, "numbers is", summation_square(n))


Enter the number of elements: 2
Enter a number: 1
Enter a number: 2
Square of the summation of 2 numbers is 9


This program is similar to the previous one where I explained about the summation, The only difference is, this program calculates the square of summation by using the ** operator to raise the summation result to the power of 2.

The program starts by asking the user to enter the number of elements. This value is stored in the variable n. The function summation_square is called with n as an argument. The returned value of the function is printed with message “Square of the summation of n numbers is “.

As before, it’s always a good practice to validate the input, in this case, make sure the entered number of elements is not negative or zero.

Python program to find the summation of n numbers


If you liked this post, then please share this with your friends and make sure to bookmark this website for more awesome content.

If You Like This Page Then Make Sure To Follow Us on Facebook, G News and Subscribe Our YouTube Channel. We will provide you updates daily.
facebook sharing button Share
twitter sharing button Tweet
whatsapp sharing button Share
telegram sharing button Share
pinterest sharing button Pin

Leave a Comment