Python Program to Print Series and Addition

Python Programming to generate a series and sum the numbers of series. In the program an input value of x and power n will be given. On the basis of input the python program will print the series along with its addition.

Python programming series and sum -How it works

Here we are working on series that print the input number first time i.e x and after that goes on printing x power n. n is a natural number starting from 1 to n. like for x=2, y=4 series will be 2 4 8 16 and sum is the sum of all its element n series 2+4+8+16=30.

Let’s write a python program

Write a program (WAP) to input value of x and n and print the series along with its sum in Python Program using while loop.

# Here series is x,x^2,x^3,x^4……………,x^n.
#sum is sum of series elements

x=float(input(“Enter the value of x”)) #to input the start value of series
n=float(input(“Enter the value of n”))#the number of value series has to be carried to
i=1 #start value is taken as 1
s=0 #sum value is taken as 0

while i<n: #it is a loop which continues untill this condition is true
y=x**i #Here y equal to x^i
print(y, “+”, end=”) #here it is printed as series
s=s+y # here sum is calculated
print(x**n) #to print the last element of series
s=s+(x**n) #to add the last element of series
print(“Sum of series =”, s)#print function shows the output on output screen

Testing the Series and Addition program

Here is the output shown for various input value.

Here the first value as input is 6 and second value the number of turn is 5 then it present 5 terms as series and sum of all the numbers . Series is 6 36 216 1296 7776 and sum of series 9330.

Congrats, our Python Program to Print Series and Addition is working fine.

Python programming series and sum source code –Click here

For more programs – Click here

Hello World Program in Python

Input a welcome message and display it in Python

Display the larger / smaller number in Python.

Greatest of Three Numbers in Python using Nested if

Patterns using nested loop in Python

Program to Print Pattern in Python

Program to input the value of x and n and sum of series in Python

Python Program for Armstrong, Prefect Number, Palindrome

Program of Prime number by recursion in python

Prime Number Program in Python

Write a Program to Print Fibonacci Series in Python

LCM and GCD program in Python

Python program to count number of vowels in a string

Whether a String is Palindrome or not in Python

Bubble Sort Program in Python

Linear search in python using list

Program to read a text file in python

Python program to read a file line by line

Program to Count Vowels and Consonants in Python

Stack Program in Python

Queue Program in Python

Python Leap Year Program for Beginners

Python Program to Print Series and Addition

Binary Search Program in Python

Program to find sum of digits in python

Sum of numbers divisible by 3 and 5 in python