Why is that when >>>(5+7)/2 gives 6.0 a floating point | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why is that when >>>(5+7)/2 gives 6.0 a floating point

quiry

2nd Oct 2018, 3:02 PM
Shadil saifi
Shadil saifi - avatar
2 Answers
+ 3
Division operation always results in a value with a floating point no matter if it is an integer or not.
2nd Oct 2018, 3:07 PM
strawdog
strawdog - avatar
+ 1
[meta] There's still enough Python 2 out there to mention that a/b results in integers (just like C) unless one of "a" or "b" is already a floating point.
2nd Oct 2018, 3:44 PM
Kirk Schafer
Kirk Schafer - avatar