Doubt on float data type | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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?????

15th Dec 2017, 3:06 AM
Sri Satya Sai
Sri Satya Sai - avatar
1 Answer
+ 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
15th Dec 2017, 3:22 AM
blackcat1111
blackcat1111 - avatar