stuck in the python program

54 views
Skip to first unread message

harleen kaur

unread,
Dec 5, 2013, 6:48:41 AM12/5/13
to pyth...@googlegroups.com
from math import *

def main():
n = abs(input("Enter a number: "))
i = 2
msg = 'is a prime number.'
while i <= sqrt(n):
if n % i == 0:
msg = 'is not a prime number.'
i = i + 1
print n, msg


main()



how to correct this program, when i run it it said, sqrt is not defined or
if i do
from math import sqrt
even though it is not working


Jinsuo Nie

unread,
Dec 5, 2013, 10:37:53 AM12/5/13
to pyth...@googlegroups.com
Your program works without any change on my machine.




--
You received this message because you are subscribed to the Google Groups "python(x,y)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonxy+u...@googlegroups.com.
To post to this group, send email to pyth...@googlegroups.com.
Visit this group at http://groups.google.com/group/pythonxy.
For more options, visit https://groups.google.com/groups/opt_out.



--
Jinsuo Nie
Reply all
Reply to author
Forward
0 new messages