Query for defining a floating number


#1

I am new to Python and recently tried to define a number in floating number 1.23 but instead used
my_int2 = 1.23
So I wanted to know whether it would be stored as am integer or a floating number and how'd we ensure that it it stored either as integer or a floating number only.
Thanks!


#2

python automatically stores decimal values as float, and non-decimal numbers as integers.

this a drawback of non-static language, you have to keep track of data types. There is type() function:

print type(my_int2)

to give you the type


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.