Python minority output program question. Help me

Asked 1 weeks ago, Updated 1 weeks ago, 1 views

Output type (number is an example) Enter numeric characters:4 Four is not a prime number I want to print it out like this, I don't know how to get that {} number you entered.(Crying) I don't know if I planned the program properly. I'd appreciate your helpcrying You have to use the repeat door!

python primes

2022-09-20 10:29

1 Answers

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.)
    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 .

2022-09-20 10:29

If you have any answers or tips

© 2022 pinfo. All rights reserved.