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

Python Program for Sum of series with source code. This python project is useful for beginners and CBSE KV School Class 11 and Class 12 students computer science practical file and NIELIT O Level Programming and Problems Solving through Python (Module M3-R5).

Objective : Write a program to input the value of x and n and print the sum of the following series in Python:

The series are given below :-

Series -1

Screen shot of source code

Explanation of Source Code

x = float (input (“Enter value of x :”)) #float value ae like 4.09
n = int (input (“Enter value of n :”)) #integer value input
s = 0 #s for calculating sum
for a in range (n + 1) : # a loop
s += x**a #sum of series element will be done in this line loop
print (“Sum of series”, s)

Output: Sum of series in python

The output shell python window will be appeared like below:-

Series 2

Screenshot of series

Explanation of Program

x = float (input (“Enter value of x :”))
n = int (input (“Enter value of n :”))
s = 0

for a in range (n + 1) :
if a%2==0:
s += xa #this caluated sum when the power is even
else: s -= xa # this is calculated when the power is odd
print (“Sum of series”, s) #sum of series element will be done in this line loop

Series 3

Screenshot of source code series 3

Explanation of Python Program

for a in range (n + 1) : #for loop starts
if a%2==0:
s += (xa)/n #odd values are negative even are postive value
else: s -= (xa)/n #sum of series element will be done in this line loop
print (“Sum of series”, s)
x = float (input (“Enter value of x :”))
n = int (input (“Enter value of n :”))
s = 0

Output : Sum of Series Program :-

Series 4

Screenshot of series 4 source code

Explanation of Python Program

x = float (input (“Enter value of x :”))
n = int (input (“Enter value of n :”))
s = 0 #inital value of sum
a=1 #initial value of a
fact=1 #factorial 1
for a in range (1,n + 1) : #for loop starts
fact=fact*a
if a%2==0:
s += (xa)/fact #sum of series element will be done in this line loop
else:
s -= (xa)/fact #sum of series element will be done in this line loop
print (“Sum of series”, s)

Ouput of Sum of series in python

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