0

Why output print ((4+8)/2) becomes 6.0????? It should be 6,not6.0

23rd Sep 2021, 8:40 PM
asma
6 Réponses
+ 4
The result of division is float by default in python.
23rd Sep 2021, 8:50 PM
Simon Sauter
Simon Sauter - avatar
+ 4
If you want to print the result as int change the type. print(int((4+8)/2)) Happy coding!
23rd Sep 2021, 8:56 PM
mesarthim
mesarthim - avatar
0
When you use a division sign it turns the number you are dividing by into a float, or a number with a decimal place. The float does not have to have a number after the decimal, it can just be a 0.
23rd Sep 2021, 9:30 PM
Elliot
Elliot - avatar
0
asma zadeh to get 6 use floor division // (4+8) // 2 = 6
24th Sep 2021, 9:09 AM
A͢J
A͢J - avatar
0
Thank you all🙂💕
26th Sep 2021, 10:30 PM
asma
- 1
print((4 + 8) / 2) 6.0
13th May 2022, 3:06 PM
MD. MAHADI