# 三元表达式:表达式1 if 条件 else 表达式2
# 示例1:
name=input('姓名>>: ')
res='SB' if name == 'alex' else 'NB'
print(res) # 输入alex为sb,其他输入都为NB
# 示例2:
x=111
y=222
res=x if x > y else y
print(res) # >>> 222
三元表达式# 三元表达式:表达式1 if 条件 else 表达式2# 示例1:name=input('姓名>>: ')res='SB' if name == 'alex' else 'NB'print(res) # 输入alex为sb,其他输入都为NB# 示例2:x=111y=222res=x if x > y else yprint(res) # >>> 222匿名函数# 匿名函数即没有名字的函数# 示例:res=(lambda