Output type (number is an example)
Enter numeric characters:4
Four is not a prime number
I want to print it out like this,
There are three ways to format strings in Python.
I prefer the fast string, so I modified it in that way.
a = int(input('number input :'))
b = 0
for i in range(2, a):
if a % i == 0:
b = 1
if b == 0:
print(f"{a} is a decimal.)
else:
print(f"{a} is not a decimal.)
Write f in front of the quotation mark of the print inquiry as above
{variable name} where the variable in quotation marks will be outputYou can write it down like .
If you search the other two methods on Google, you can find them well, so please refer to them.
* When you upload the code, type it in text and wrap the beginning and end with `` and ``, and it goes up nicely. If you post it as a picture, it may be difficult to get an answer because you have to type it yourself.
* The method of finding the decimal point of the source works properly. However, it can take a long time if a large number goes in. I think it would be good to refer to Eratosthenes' sieve .
© 2024 OneMinuteCode. All rights reserved.