Python基础 if条件

来源:互联网 发布:阿里云总部地址 编辑:程序博客网 时间:2024/06/06 00:13

if条件

x=1y=2z=3if x>y:    print('x is greater than y.')if x<y:    print('x is less than y.')if x<y<z:    print('x is less than y,and y is less than z.')
a=2b=2if a==b:    print('a is equal to y.')if a!=b:    print ('a is not equal to y.')

if else条件

x=1y=2z=3if x>y:    print('x is greater than y.')else:    print('x is less or equal to y.')

if elif else条件

x=1y=2z=3if x>y:    print('x is greater than y.')elif x>y:    print('x is less or equal to y.')else:    print(x)
原创粉丝点击