题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
def approximate_integer(value): # 将小数点后的部分提取出来 decimal = value - int(value) # 如果小数点后的数值大于等于 0.5,则向上取整 if decimal >= 0.5: return int(value) + 1 else: return int(value) # 获取用户输入 input_value = float(input()) # 调用函数并输出结果 approximated_integer = approximate_integer(input_value) print(f"{approximated_integer}")