如何检查浮点值是否大于python中的另一个浮点值?

时间:2022-08-21 17:08:43

I have to check if the input value is greater than 0.00125 in python. The code is

我必须在python中检查输入值是否大于0.00125。代码是

if float(line) > 0.00125

It is not checking the value. Is there any other keyword for doing this?

它没有检查值。这样做还有其他关键字吗?

1 个解决方案

#1


Did you use raw_input for getting the user input? This works perfect.

您是否使用raw_input获取用户输入?这很完美。

line = raw_input("Type a float: ")
if (float (line) > 0.00125):
    print "input is bigger"
else:
    print "input is lower"

#1


Did you use raw_input for getting the user input? This works perfect.

您是否使用raw_input获取用户输入?这很完美。

line = raw_input("Type a float: ")
if (float (line) > 0.00125):
    print "input is bigger"
else:
    print "input is lower"