Search This Blog
Available Codings for Programming of C, C++, PYTHON, JAVA and HTML.
Welcome to Coding 4 Programming
- Get link
- X
- Other Apps
Labels
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.
- n=int(input("Enter a Number="))
- prime= True
- for i in range(2,n):
- if(n%i==0):
- prime= False
- if prime:
- print(f"{n} is Prime Number")
- else:
- print(f"{n} is Not Prime Number")
- Visual Studio Code Screenshot of the Above Program with Output.
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 single, double, 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.
- Get link
- X
- Other Apps
Labels:
Python
Popular Posts
To Check Perfect Number | Function | For Loop | Python
- Get link
- X
- Other Apps
Comments
Post a Comment