- 2

Why is the answer to ((8+4)/2) 6.0 and not 6.

7th Jul 2021, 9:45 AM
TIREHEAD
3 odpowiedzi
+ 7
TIREHEAD , you have not mentioned the programming language you are using. assuming it is python: ▪︎all results from a division in python are float numbers. so the result is 6.0
7th Jul 2021, 10:56 AM
Lothar
Lothar - avatar
+ 4
The answer of 6.0 would depend on the programming language for used. In most the result would actually be an int, when / is used, truncating the fractional portion. I'm guessing that you're using Python, since this seems to be the course you're doing. In Python the use of the / operator will result in a floating point number and the // operator will result in floor division or integer division.
7th Jul 2021, 10:58 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
TIREHEAD In python you will always get output in decimal because normal division (/) returns value with fraction part. If you don't want like that then use floor division (//) (8 + 4) // 2 #gives 6 (8 + 4) / 2 # gives 6.0 floor division returns without fraction part.
7th Jul 2021, 2:04 PM
A͢J
A͢J - avatar