int and float in Python?int represents whole numbers without decimals, like 5 or -3.
float represents numbers with decimals, like 3.14 or -0.001.
/ in Python?The result is always a float, even if the division is exact.
Example: 4 / 2 gives 2.0, not 2.
float to an int in Python?Use the int() function. It removes the decimal part (truncates).
Example: int(3.9) becomes 3.
int(3.9999) and why?The result is 3 because int() cuts off the decimal part without rounding.
Because floats are stored in a way that can’t exactly represent some decimal numbers, small rounding errors can happen.
Example: 0.1 + 0.2 might not exactly equal 0.3.
5 / 2 return in Python?Division with / always returns a float, so 5 / 2 is 2.5.
int(7.8) return?int() truncates the decimal part, so 7.8 becomes 7.
3.0 is a float. 3 is an int, "3.0" is a string, and 3,0 is invalid syntax.
0.1 + 0.2 == 0.3 in Python?Due to floating point precision, 0.1 + 0.2 is not exactly 0.3, so the expression is False.
5 to a float?float(5) converts the integer 5 to the float 5.0.
int and float types in Python and how division behaves with these types.