0
Why the output is coming as 5.0 on 10/5
Please
3 Respuestas
+ 2
The explanation is in the yellow box in the second page in this lesson:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2272/
Oh sorry should be yellow box of second page of this lesson:
https://www.sololearn.com/learn/Python/2271/
Anyway, these yellow box notes are important.
+ 1
2.0 or 5.0?
Edit:
In what language?
If it python, / operator consider those operand as a floating numbers.. So ouput 2.0
If you want 5 as answer, you have use // floor division operator..
10//5=2
10/5=2.0
+ 1
To explain more:
In more basic language, you need to declare the type of numbers differently.
https://www.sololearn.com/learn/C/2912/
in C, int for integer, float for decimals. The computer will then allocate memory accordingly.
In simple words, you need more memory if the number is decimal.
Python, and JavaScript, converts types automatically. They can sometimes be tricky.