Why Avg output is float? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
4th Mar 2022, 6:23 AM
Apu
Apu - avatar
2 Respostas
+ 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