0
What is the basic definition of an integer and a float?
What are the Main uses for each type and what are the differences
4 Réponses
+ 3
That may be, but since Python 2 will be a goner soon, I think it's safe to assume OP (seemingly just starting out) is talking about Py 3.
+ 2
In Python, there's only float and int.
Ints are whole numbers (that don't overflow, they can become as big as you need).
Floats are numbers with decimal places. Computers can't be perfectly precise with them. So you basically use them when:
1.) you need decimals (obv)
2.) AND accuracy doesn't matter too much.
+ 1
Integer 0
Float 0.000000 (7 digits)
Double 0.0000000000 (15 digits)
Decimal 0.0000000000000000 (28 digits)
Ok now we now that if you need to use any digits we should not use integer and also there is a max limit for integer
32767 which is 2^15
if you use integer and give a value over 32767 you will have problems you should use long instead of integer