Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement 使用<&&燃气轮机;(小于和大于)在Jython中的if语句中_If Statement_Jython - Fatal编程技术网

If statement 使用<&&燃气轮机;(小于和大于)在Jython中的if语句中

If statement 使用<&&燃气轮机;(小于和大于)在Jython中的if语句中,if-statement,jython,If Statement,Jython,我正在编写一个小程序,它需要一些if语句,例如: number=x/(y*y) if number <5: print "blahblahblah" if number >5 or <10: print "blahblahblah" if number >10.5 or >15.0: print "blahblahblah" if number >15: print "blahblahblah" number=x/(y*y) 如果数字

我正在编写一个小程序,它需要一些if语句,例如:

number=x/(y*y)

if number <5:
  print "blahblahblah"

if number >5 or <10:
  print "blahblahblah"

if number >10.5 or >15.0:
  print "blahblahblah"

if number >15:
  print "blahblahblah"
number=x/(y*y)
如果数字5或10.5或>15.0:
打印“blahblahblah”
如果数字>15:
打印“blahblahblah”
基本上,我在if语句中使用>和<时遇到了问题,无法确定如何说“if小于4或大于5”

当我加载程序时,出现以下错误-

无效语法 您的代码至少包含一个语法错误,这意味着它不是合法的jython

非常感谢您的帮助

给您:

if number > 10 and number < 20 then:
   print "Number between 10 and 20"
如果编号>10且编号<20,则:
打印“10到20之间的数字”

每个比较都是一个独立的表达式,与
等组合在一起。

作为Paul answer与
等的补充,如果5
,您可以使用

if number < 5:
    print("a")

if 5 < number < 10:
    print("b")

if 10 < number < 15:
    print("c")

if number > 15:
    print("d")

顺便说一句,在你的代码中,你使用了
而不是

意识到“if>5或该条件是错误的。它将始终返回true。我假设你的意思是
如果number>10和number<20,那么
来证明你必须在这两个位置指定数字。是的是的。:p快速键入FTL。
if number < 5:
    print("a")
elif number < 10:
    print("b")
elif number < 15:
    print("c")
else:
    print("d")