Python中大于0.5的数字转化为1
作者:野牛程序员:2023-12-05 16:35:38python阅读 2786
Python中大于0.5的数字转化为1
# 输入一个数字 input_number = 0.7 # 你可以替换这里的数字 # 将大于0.5的数字转化为1 result = 1 if input_number > 0.5 else input_number # 打印结果 print(result)
野牛程序员教少儿编程与信息学奥赛-微信|电话:15892516892
