0% found this document useful (0 votes)
11 views9 pages

Neelasmeeta. Computer

Uploaded by

amitnabadwip50
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)
11 views9 pages

Neelasmeeta. Computer

Uploaded by

amitnabadwip50
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/ 9

NAME: NEELASMEETA DAS

ROLL NO.: 04
SECTION: A
BATCH:
B.SC(HONS)
FORENSIC SCIENCE
SUBJECT: PYTHON
PROGRAMMING
Write a python program to check whether a number is
prime or not.

n=int(input("enter a number"))
lb=2
ub=n-1
c=0
for i in range(lb,ub+1):
if n%i==0:
c=c+1
if c==0:
print("It is a prime number")
else:
print("It is not prime")

Write a python program to print all the armstrong


numbers in a range.
print("Enter the range")
x=int(input("the starting value"))
y=int(input("the last value"))
c=0
for i in range (x, y+1, 1):
j=i
l=i
s=0
d=0
while(i>0):
d=d+1
i//=10
while (l>0):
n=l%10
l//=10
s+=n**d
if(s==j):
print(s)
c=c+1 if(c==0):
print("No Armstrong number found")

Write a python program to calculate the GCD and LCM


of two numbers.

a1=int(input("Enter first number"))


a2=int(input("Enter second number"))
hcf=0
for i in range(1,a1+1):
if(a1%i==0 and a2%i==0):
hcf=i
print("HCF=",hcf)
lcm=0
lcm=(a1*a2)/hcf
print("LCM",lcm)

Write a python program to print all the prime factors of a


number.
n=int(input("enter a number"))
for i in range(2,n):
c=0
if n%i==0:
for j in range(2,i):
if i%j==0:
c=c+1
if (c==0):
print (i)

Write a python program to find the divisor of a number.

n=int(input("enter a number"))
lb=1
ub=n
for i in range(lb,ub+1):
if n%i==0:
print(i)
Write a python program to check whether a number is
perfect or not.

n=int(input("enter a number"))
m=n
lb=1
ub=n-1
s=0
for i in range(lb,ub+1):
if n%i==0:
s=s+i
if s==m:
print("Perfect number")
else:
print("Not a perfect number")

Write a python program to calculate the S.I and the C.I .


p=int(input("enter the principle"))
r=int(input("enter the rate"))
t=int(input("enter the time"))
n=int(input("enter the number of times interest is compounded
per year"))
si=(p*r*t)/100
m=n*t
a=r/n
a=p*((1+a)**m)
ci=a-p
print("the simple interest is",si)
print("the compound interest is",ci)

Write a python program to check whether a number is


automorphic or not.

n=int(input("enter a number"))
d=0
s2=0
m=n
s=n**2
while(n>0):
d=d+1
n=n//10
f=10**d
s2=s%f
if (s2==m):
print("automorphic")
else:
print("not automorphic")

Write a python program to print all the numbers between


1 to 100 which is divisible by 3.

lb=1
ub=100
for i in range(lb,ub+1):
if i%3==0:
print(i)
By the input of a person’s age find out the age group
(child, teenager, adult, senior).

a=int(input("enter the age"))


if a<13:
print("child")
elif (a>=13 and a<18):
print("teenager")
elif (a>=18 and a<60):
print("adult")
else:
print("senior")

You might also like