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/ Explanation:

Enter the value of n : 5

Enter the value of a : 2

Sum of the series= 0.96875

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad