Python program to check the prime number.

In this python basic program, we will check the whether the given number is a prime number.

Steps to solve the program
  1. Take a number as input through the user and create a count variable and assign its value equal to 0.
  2. Use for loop with the range function to check whether a number is a prime number or not.
  3. If a number divides the input number then add 1 to the count variable.
  4. If a number is divisible by 1 and by itself then it is a prime number.
  5. Print the output.
				
					num = int(input("Enter a number: "))
count = 0

for i in range(1,num+1):
    if num%i == 0:
        count += 1
        
if count == 2:
    print(f"{num} is a prime number")
else:
    print(f"{num} is not a prime number")
				
			

Output :

				
					Enter a number: 53
53 is a prime number
				
			

calculate compound interest.

check leap year.

Leave a Comment