** WAP to input a number and check whether it is prime number or not in Python**

**Prime Number** – a number that is divisible only by itself and 1. Example 3,5,7.etc. for this program it has to check every number up to n(The number to be checked) throughout using for loop iterative statement .

### WAP the Prime Number Program using Python

The python code for the program to accept a number and produce out put is given below :-

**Describe the Code**

n=int(input(“Enter the number”)) #input of the number that needs to be checked whether it is prime or not

c=1 #creating of a variable c and initialization.

for i in range(2,n): #for loop and creating a variable i and variable going from intial 2 to n the number first input

if n%i==0: # this loop will go on to the last n to check whether the value n is divisible by i.

c=0 # if above condition becomes true then c value becomes zero

if c==1:If c remains 1 then the output is printed that this number is Number is prime

print(“Number is prime”)

else:

print(“Number is not prime”) #If it comes as c not equal to 1 then it is printed Number is not prime.

**Output of our Prime Number Program**

Here the first input is 9 which is divisible by 1,3,9 so it does not fulfil the condition to be a prime number. The 3 is the extra number which loop finds and change the value of c=0 which in turn print that Number is not a prime .

then we type 2 which is divisible by 1,2 and so it is a prime number.

Download source code – click here

So, This is prime number program in python.

for more program- click here

**Input a welcome message and display it in Python**

**Display the larger / smaller number in Python.**

**Greatest of Three Numbers in Python using Nested if**

**Patterns using nested loop in Python**

**Program to Print Pattern in Python**

**Program to input the value of x and n and sum of series in Python**

**Python Program for Armstrong, Prefect Number, Palindrome**

**Program of Prime number by recursion in python**

**Prime Number Program in Python**

**Write a Program to Print Fibonacci Series in Python**

**Python program to count number of vowels in a string**

**Whether a String is Palindrome or not in Python**

**Linear search in python using list**

**Program to read a text file in python**

**Python program to read a file line by line**

**Program to Count Vowels and Consonants in Python**

**Python Leap Year Program for Beginners**

**Python Program to Print Series and Addition**

**Binary Search Program in Python**