0% found this document useful (0 votes)
7 views4 pages

Series Printing in Python-1

computer programming

Uploaded by

pauloindrisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Series Printing in Python-1

computer programming

Uploaded by

pauloindrisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

SERIES PRINTING IN PYTHON

1. Program to find the sum of series 1+2+3..+N


print("Enter the range of number:")

n=int(input())
sum=0
for i in range(1,n+1):
sum+=i
print("The sum of the series = ",sum)

2. Program to find the sum of series 1+3+5+7..+N

print("Enter the range of number:")

n=int(input())
sum=0
i=1
while(i<=n):
sum+=i
i+=2
print("The sum of the series = ",sum)
3. Print the series like -1,4,-7,10, ------n term.

print("Enter the range of number(Limit):")


n=int(input())
i=1
se=1
while(i<=n):
if(i%2==0):
print(se,end=" ")
else:
print(-1*se, end=" ")
se+=3
i+=1

4. Program to print series 10,5,60,15,110...N

print("Enter the range of number(Limit):")


n=int(input())
a=10
b=5
i=1
while(i<=n):
if(i%2==0):
print(b,end=" ")
b += 10
else:
print(a, end=" ")
a += 50
i+=1

5. Program to print Fibonacci series


print("Enter the range of number(Limit):")
n=int(input())
i=1
a=0
b=1
c=a+b
while(i<=n):
print(c,end=" ")
c=a+b
a=b
b=c
i+=1
6. Program to Print Cube Number series 1 8 27 64...N.
print("Enter the range of number(Limit):")
n=int(input())
i=1
while(i<=n):
print(i*i*i,end=" ")
i+=1

7. WAP to print the series like 1 15 151 1515 ---- n term.

print("Enter the range of number(Limit):")


n=int(input())
i=1
d=5
while(i<=n):
print(i)
i=(i*10)+d
d=6-d

8. WAP to print the series like 1 3 7 ----- n term.

print("Enter the range of number(Limit):")


n=int(input())
i=1
d=2
while(i<=n):
print(i)
i=i+d
d=d*2

9. WAP to calculate simple interest.


p=int(input("Enter the principal amount"))
n=int(input("Enter the year"))
r=int(input("Enter the rate of interest"))
si=(p*r*t)/100
print("Simple interest=",si)
10. WAP to check those numbers between 1 to n which is divisible by 3
and 5
def result(N):

# iterate from 0 to N
for num in range(N):

# Short-circuit operator is used


if num % 3 == 0 and num % 5 == 0:
print(str(num) + " ", end = "")

else:
pass

# Driver code
if __name__ == "__main__":

# input goes here


N = 100

# Calling function
result(N)

You might also like