1# test round() with floats 2 3# check basic cases 4tests = [ 5 [0.0], 6 [1.0], 7 [0.1], 8 [-0.1], 9 [123.4], 10 [123.6], 11 [-123.4], 12 [-123.6], 13 [1.234567, 5], 14 [1.23456, 1], 15 [1.23456, 0], 16 [1234.56, -2], 17] 18for t in tests: 19 print(round(*t)) 20 21# check .5 cases 22for i in range(11): 23 print(round((i - 5) / 2)) 24 25# test second arg 26for i in range(-1, 3): 27 print(round(1.47, i)) 28 29# test inf and nan 30for val in (float("inf"), float("nan")): 31 try: 32 round(val) 33 except (ValueError, OverflowError) as e: 34 print(type(e)) 35