Curious Math Question in Python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Curious Math Question in Python?

Here is the question ==> Which option is output by this code? >>> (4 + 8) / 2 Now why is my answer wrong when I picked 6 but it is right when I pick 6.0 they mean the same thing.

23rd Jan 2017, 6:37 PM
Amari Hanes
1 Answer
0
Actually, all normal divisions are float divisions, so they return a float result, hence 6.0 If it was integer division, you would use //
23rd Jan 2017, 7:12 PM
Amaras A
Amaras A - avatar