热线电话:13121318867

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

8. lt(a,b): - 此函数用于检查a是否小于b。如果a小于b则返回true,否则返回false。
操作 - a <b

9. le(a,b): - 此函数用于检查a是否小于或等于b。如果a小于或等于b,则返回true,否则返回false。
操作 - a <= b

10. eq(a,b): - 该函数用于检查a是否等于b。如果a等于b,则返回true,否则返回false。
操作 - a == b

# Python code to demonstrate working of

# lt(), le() and eq()

# importing operator module

import operator

# Initializing variables

a = 3

b = 3

# using lt() to check if a is less than b

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

print ("3 is less than 3")

else : print ("3 is not less than 3")

# using le() to check if a is less than or equal to b

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

print ("3 is less than or equal to 3")

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

# using eq() to check if a is equal to b

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

print ("3 is equal to 3")

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

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

发表评论

暂无数据
推荐帖子