# Python champak
₹2,000.00 ₹300.00 • 22 students
• 41 lessons
• 0 quizzes
• 10 week duration

## Python

### Summation of Series

To sum the series 1+2+3+4+… +n

#sum from 1 to n
n=10
sum=0
for i in range(1,n+1):
—sum=sum+i
print(“Sum from {0} to {1} is {2}”.format(1,n,sum))

Ans 55

To sum a series from a to b

#sum from a to b
a=5
b=7
sum=0
for i in range(a,b+1):
—sum=sum+i
print(“Sum from {0} to {1} is {2}”.format(a,b,sum))

Ans 18

To sum the series 1,-2,3,-4,5,-6,…-10. Alternately positive  and negative

# 1,-2,3,-4,5,-6,…-10
a=1
b=10
t=1
sum=0
for i in range(a,b+1):
—x=t*i
—sum=sum+x
—print(x,end=”,”)
—t=-t
print(“\nSum from {0} to {1} is {2}”.format(a,b,sum)) To sum the series 1! + 2! + 3! + 4! + 5!

#To sum the series 1! + 2! + 3! + 4! + 5!
a=1
b=5
f=1
sum=0
for i in range(a,b+1):
—f=f*i
—sum=sum+f
—print(f,end=”,”)

print(“\nSum from fact({0}) to fact({1}) is {2}”.format(a,b,sum)) To sum the sine series x-x^3/3!+x^5/5!-x^7/7!+….

#To sum the sine series x-x^3/3!+x^5/5!-x^7/7!+….
a=1
b=10
angle=30
x=angle*3.1415927/180
sum=0
term=x
for i in range(a,b+1):
—sum=sum+term
—term=-term*x*x/(2*i*(2*i+1))

print(“\nSine of({0}) is {1}”.format(angle,sum)) Try the following problems

1. Sum the cosine series
2. Find the sum of 1*2 + 2*3 + 3*4 ,…..
3. Find the sum of 1/1 + 1/2 + 1/3 + 1/4…..