Whats the difference between 6 & 6.0? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Whats the difference between 6 & 6.0?

i think both are the same but why do Python treat them differently?

12th Aug 2018, 7:42 AM
차영환
차영환 - avatar
3 Answers
+ 6
6 is an integer. 6.0 is a floating-point value.
12th Aug 2018, 7:53 AM
Hatsy Rei
Hatsy Rei - avatar
0
in most programming language: 6 = int. 6.0 = double. 6.0f or 6.f = float.
12th Aug 2018, 8:00 AM
Cain Eviatar
Cain Eviatar - avatar
0
6 indicates integer value. whereas 6.0 indicates floating. if you declare integer but used floating value the calculation will be shown wrong. ex: you declared int x, but used x=6.86. the printf will show 6 only.
12th Aug 2018, 8:13 AM
Aniruddha Sarkar
Aniruddha Sarkar - avatar