0
Doubt on float data type
If we use float data type and then if write 1+2+3 then is the output is 6.0?????
1 Resposta
+ 5
Technically in Python you do not declare the variable type when declaring a variable;
a = 1+2+3
print(a)
>>>6
print(isinstance(a, int))
print(isinstance(a, float))
>>>True
>>>False
... Unless you convert a to float beforehand;
a = 1+2+3
print(a)
>>>6
a = float(a)
print(a)
>>>6.0
print(isinstance(a, int))
print(isinstance(a, float))
>>>False
>>>True