热线电话:13121318867

登录
2018-12-18 阅读量: 813
python常用的运算函数(4)

11. gt(a,b): - 此函数用于检查a是否大于b。如果a大于b,则返回true,否则返回false。

操作 -a> b

12. ge(a,b): - 此函数用于检查a是否大于或等于b。如果a大于或等于b,则返回true,否则返回false。
操作 - a> = b

13. ne(a,b): - 此函数用于检查a是否不等于b或相等。如果a不等于b,则返回true,否则返回false。
操作 - a!= b

# Python code to demonstrate working of

# gt(), ge() and ne()

# importing operator module

import operator

# Initializing variables

a = 4

b = 3

# using gt() to check if a is greater than b

if (operator.gt(a,b)):

print ("4 is greater than 3")

else : print ("4 is not greater than 3")

# using ge() to check if a is greater than or equal to b

if (operator.ge(a,b)):

print ("4 is greater than or equal to 3")

else : print ("4 is not greater than or equal to 3")

# using ne() to check if a is not equal to b

if (operator.ne(a,b)):

print ("4 is not equal to 3")

else : print ("4 is equal to 3")

0.0000
5
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子