Skip to main content

Welcome to Coding 4 Programming

Addition of Two Binary Numbers | Function | Python

To Check Prime Number | For Loop | Python

Python Program to check whether Entered Number is Prime Number or Not, through For Loop.

  • Coding for the Above Program.

  1. n=int(input("Enter a Number="))
  2. prime= True
  3. for i in range(2,n):
  4.     if(n%i==0):
  5.         prime= False
  6. if prime:
  7.     print(f"{n} is Prime Number")
  8. else:
  9.     print(f"{n} is Not Prime Number")


  • Visual Studio Code Screenshot of the Above Program with Output.

Prime Number
To Check Prime Number in Python

  • New Concept:

In Line 6 and 7, there is new concept of f-string.

Every f-string statement consists of two parts, one is character f or F, and the next one is a string which we want to format. The string will be enclosed in singledouble, or triple quotes.

Example: f"String" 

The variables in the curly { } braces are displayed in the output as a normal print statement. Let's see an example.

print(f "{Variable 1} String {Variable 2} String. ") 

 

 Notes:

  • If you have any problem related to this program. Please do comment your Problem or Mail us.
  • For illustrating the any concept you can comment by line number.
  • Thank you! For more programs do regular visit to Coding 4 Programming.

Comments

Popular Posts