Feb-13-2023, 11:13 PM
Simple division always creates a float. You can check if the float is an integer and convert back if you would like.
quotient = 10 / 5 if quotient.is_integer(): quotient = int(quotient) print(quotient)Floor division always rounds down. It doesn't round toward zero if that's what you're expecting.