https://www.cnblogs.com/xuexianqi/p/12564720.html

def func(x,y):
    if x > y:
        return x
    else:
        return y

res = func(1,2)
print(res)

二:三元表达式

语法格式:条件成立时返回的值 if 条件 else 条件不成立时要返回的值

x = 1
y = 2

res = x if x > y else y
print(res)
egon = 18
alex = 80

res = 'egon是儿子' if egon < alex else 'alex是爸爸'
print(res)

相关文章:

  • 2022-12-23
  • 2021-09-26
  • 2021-08-08
猜你喜欢
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
  • 2021-06-21
相关资源
相似解决方案