You are on page 1of 4

1.

amrish
2. anantha
3. cherishma
4. darun
5. harish
6. nitesh
7. tarika
8. pradeesh
9. raja sai
10. dawin
11. seetha lakshmi
12. ritesh
13. sailesh
14. sakthipriya
15. sreevass
16. sanjiv
17. magdaleena
18.mritunjay
19. prithiksha
20. mahitha
21. sanjitha
22. shreya
23. pranetha
24. pranav kumaar.
25. arya

functions with for loop


1. write a python program to get n value find the
following sum of series.
1+2+3+........n
n=int(input("enter n value"))
sum=0
for i in range(1,n+1):
sum=sum+i
print("sum value=",sum)
note
for loop range(1,5)
print(i)
1
2
3
4 => stoped here before 5

2)write a the python function sumseries(n) to find the


sum of series.
1+2+3+........n
solution:
def sumseries(n):
sum=0
for i in range(1,n+1):
sum=sum+i
print("sum value=",sum)
n=int(input("enter n value"))
sumseries(n)
3) write a python program to find the following
sum of series.
1x+2x+3x+.......nx => 1* x
solution:
n=int(input("enter n value"))
x=int(input("enter x value"))
sum=0
for i in range(1,n+1):
sum=sum+i*x
print("sum value=",sum)
task
4)write apython function sumseries() and pass x,n
as a arugment and find the following sum of series.
1x+2x+3x+.......nx

solution:
def sumseries(n,x):
sum=0
for i in range(1,n+1):
sum=sum+x*i
print("sum value=",sum)
n=int(input("enter n value"))
x=int(input("enter x value"))
sumseries(n,x)

5)write a python program to find the following follwing


sum of series using function .
1x^1+2x^2+3x^3+.........nx^n
i*x**i
solution:
def sumseries(x,n):
sum=0
for i in range(1,n+1):
sum=sum+i*x**i
print("sum value=",sum)
x=int(input("enter x value"))
n=int(input("enter n value"))
sumseries(x,n)

6)write a python function findfact() and pass n


as argument and find the factorial of the given n.
n=5 => 5!=> 1*2*3*4*5
solution:
def findfact(n):
fact=1
for i in range(1,n+1):
fact=fact*i
print("factorial value=",fact)
n=int(input("enter n value")
findfact(n)

"""
i=1 fact=fact*i=> 1*1=> 1
i=2 fact=fact*i => 1*2 =. 2
i=3 fact=fact*i=> 2*3=> 6
i=4 fact=fact*i => 6*4 => 24
i=5 fact=fact* i=> 24*5 => 120

"""

You might also like