What is the basic definition of an integer and a float? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

25th Apr 2019, 12:09 PM
Mohsen Benyan
Mohsen Benyan - avatar
4 Answers
+ 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.
25th Apr 2019, 1:18 PM
HonFu
HonFu - avatar
+ 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.
25th Apr 2019, 12:38 PM
HonFu
HonFu - avatar
+ 2
HonFu *In Python 3. Python 2 has int, float and long.
25th Apr 2019, 1:18 PM
Diego
Diego - avatar
+ 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
25th Apr 2019, 12:31 PM
Melih Melik Sonmez
Melih Melik Sonmez - avatar