Why Avg output is float? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
4th Mar 2022, 6:23 AM
Apu
Apu - avatar
2 Answers
+ 2
It is by default, python gives an output in terms of double precision float number. You can do this if you don't want float number avg = int((a + b)/2)
4th Mar 2022, 6:36 AM
👑 ShadowCipher 🇦🇲
👑 ShadowCipher 🇦🇲 - avatar
+ 1
Prakash Dhar Lesson 3.1, second section of "Python fir Beginners" has this written in a yellow box. Using a single slash to divide numbers produces a decimal (or float, as it’s known in programming). We'll dive into floats in the next lesson. You may wish to review that lesson and play with the code example
4th Mar 2022, 8:55 AM
Rik Wittkopp
Rik Wittkopp - avatar