Relational Operator

Relational Operator

關係運算子

關係運算子有六個

運算子
解釋
範例

==

等於

1==1

!=

不等於

2!=1

>

大於

2>1

<

小於

1<2

>=

大於等於

2>=1

<=

小於等於

1<=1

範例

print(1==1)
print(1<=1)
print('hello' == 'hello')
print('hello' == 123)
print('123' == 123)
print((1==1) and (1>=1))

Last updated

Was this helpful?