0% found this document useful (0 votes)
43 views

Q1: Python Program To Find A Number Is Prime or Not? Input : Output

This document contains 5 Python programs: 1) to check if a number is prime, 2) to print the multiplication table of a number, 3) to calculate the factorial of a number, 4) to check if a number is even or odd, and 5) to calculate the sum of natural numbers up to a given range. For each program, the input code and expected output are provided.

Uploaded by

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

Q1: Python Program To Find A Number Is Prime or Not? Input : Output

This document contains 5 Python programs: 1) to check if a number is prime, 2) to print the multiplication table of a number, 3) to calculate the factorial of a number, 4) to check if a number is even or odd, and 5) to calculate the sum of natural numbers up to a given range. For each program, the input code and expected output are provided.

Uploaded by

Computer Tricks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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