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 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz