You are on page 1of 5

Q1: Python Program to find a Number is Prime or Not?

INPUT #Python Program to check a number is prime or not


n=int(input("Enter a number --> "))
c=0
for i in range(1,n+1):
if n%i==0:
c=c+1
if c==2:
print"This is prime number --> ",n
else:
print"This is not prime number --> ",n
OUTPUT 
Q2: Python Program to print the table of the number?
INPUT #Python Program to print a table
n=int(input("Enter a number for table --> "))
for i in range (1,11):
print n,"*",i,"=",n*i

OUTPUT:
Q3: Program to print the factorial number of input?
INPUT #Python Program to find Factorial number
n=int(input("Enter any number to find factorial --> "))
fact=1
for i in range(n,0,-1):
fact=fact*i
print " Factorial number is --> ",fact

OUTPUT:
Q4: Python Program to find a number is Even or Odd?
INPUT # Program to check a number is Even & Odd
n=int(input("Enter a number --> "))
if n%2==0:
print "This number is even number --> ",n
else:
print "This number is odd number --> ",n

OUTPUT:
Q5: Python Program to enter a range of sum of
natural number?
INPUT # to find out sum of natural number till the range input
n=int(input("Enter a range --> "))
sum=0
for i in range(1,n+1):
sum=sum+i
print "The sum of natural number till the range is --> ",sum

OUTPUT:

You might also like