This is my code:
def isPrime(n):
if n>1:
for i in range(2, n):
if (n%i)== 0:
print(n, "is not a prime number")
print(i, "*", n//i, "=", n)
break
else:
print(n, "is a prime number")
else:
print(n, "is not a prime number")
Earlier I have used idle and Jupyter notebook but now I am trying to run it via command line and I don't know how to enter argument for the function defined. I'm using cmd for the first time for running scripts. This is what it shows:
You can use the flag -c while doing python like this:
python -c 'isPrime(11)'
you can also import this way as well
python -c 'import foo; foo.isPrime(2)'
or do this
python -c 'from foo import isPrime; foo.isPrime(n)'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With