<p>我是Python新手,写了这个代码来识别一个数是否是素数。
我写了一个可以用JavaScript和visualbasic工作的代码,但不能用Python工作,错误是:<strong>TypeError:浮点是必需的</strong>。
我的代码:</p>
<pre><code>import math
a = raw_input("Enter a number:")
k = 0
i = 1
s = math.sqrt(a)
while i <= s:
if a % i == 0:
k += 1
i += 1
if k == 2:
print "prime num"
else:
print "normal num"
</code></pre>
<p>怎么了?你知道吗</p>