0
What is my mistake? I've written the code in many ways but there is something wrong about float and zero division(line 4 and3).
#my_code_: i = float (input('the number is:\n')) i>0 x= float in range(2.0,i) x>0 if i%x > 0: print("i is prime") else : print ("i is not a prime number") print(i)
1 Réponse
+ 1
To be honest with you, there's quite a lot wrong here.
i = float (input('the number is:\n'))
#this line is fine
i>0 #doesn't do anything
x= float in range(2.0,i)
# this is very wrong. range() method always takes integers (whole numbers) as arguments not floats like 2.0. What are you trying to do here? You may need to return to the Python course to redo this.
x>0 #again, does nothing
if i%x > 0:
print("i is prime")
else :
print ("i is not a prime number")
print(i)
#rest is good.