C-16-Q066mediumsingle_mcq
The behaviour of int(2.8) returning 2 shows that int() on a float:
The behaviour of int(2.8) returning 2 shows that int() on a float:
- arounds to the nearest integer
- bdiscards the fractional part (truncates toward zero)
- calways rounds up
- draises an error
ব্যাখ্যা
int() does not round a float; it simply drops the fractional part, truncating toward zero. That is why int(2.8) gives 2 rather than 3.