I have TypeError: a float is required when I try putting type() with if statement
example:
from math import *
x=input("Enter a Number: ")
if type (sqrt(x)) == int:
print (sqrt(x))
else:
print("There is no integer square root")
obviously I can't use x= float(x)
x= float(x)” – why not?float.is_integermethod to test if a float is an int.isinstance.TypeError: a float is required. That's becausexis a string. You can't take a square root of a string. Do note that even if you dosqrt(float(x))your if-statement will never evaluate to true becausemath.sqrtalways returns a float.