Programming Examples

Python program to find the sum of first ten terms of the series


Write a Code in Python to display the first ten terms of the series:

import math
sum=0
n=int(input("Enter the value of n : "))
a=int(input("Enter the value of a : "))
for p in range(1, n+1):
    sum=sum+1/math.pow(a,p)
print("Sum of the series=",sum)

Write a code in Python to compute and display the sum of the series:

Solution:

Solution 

sum=0
s1=s2=1
n=int(input("Enter the value of n : "))
for p in range(1, n+1):
    s1=s1+(p+1)
    s2=s2*(p+1)
    s=s1/s2
    sum=sum+s
print("Sum of the series=",sum)
Output

Enter the value of n : 5

Enter the value of a : 2

Sum of the series= 0.96875

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad