当前位置: 首页 > news >正文

云浮 网站建设/品牌营销策划

云浮 网站建设,品牌营销策划,wordpress html音乐,seo网站是什么### 多项分支"""语法:if 条件表达式1:code ...code ...elif 条件表达式2:code ...code ...elif 条件表达式3:code ...code ...else:code ...code ...如果条件表达式1成立,就执行1当中的代码块,如果不成立,向下执行如果条件表达式2成立,就执行2当中的代码块,如果…

### 多项分支

"""

语法:

if 条件表达式1:

code ...

code ...

elif 条件表达式2:

code ...

code ...

elif 条件表达式3:

code ...

code ...

else:

code ...

code ...

如果条件表达式1成立,就执行1当中的代码块,如果不成立,向下执行

如果条件表达式2成立,就执行2当中的代码块,如果不成立,向下执行

如果条件表达式3成立,就执行3当中的代码块,如果不成立,向下执行

直到最后,没有一个条件满足,直接执行else这个分支;

从多个条件分支当中选1个;

elif 可以是0个也可以是多个

else 可以是0个也可以是1个

"""

youqian = True

双项分支

if youqian == True:

print("我就立刻嫁给你,办手续")

else:

print("你是个好人 ... ")

多项分支

youqian = True

youfang = True

youche = True

youyanzhi = True

youtili = True

if youqian == False:

print("我就嫁给你1")

elif youfang == False:

print("我就嫁给你2")

elif youche == False:

print("我就嫁给你3")

elif youyanzhi == False:

print("我就嫁给你4")

elif youtili == False:

print("我就嫁给你5")

else:

print("你出家吧,当我穿上了婚纱,你也披上了袈裟")

### 巢状分支 (单项分支 双项分支 多项分支的互相嵌套)

if youqian == True:

if youfang == True:

if youche == True:

if youyanzhi == True:

if youtili == False:

print("老娘要嫁给你111")

else:

print("恭喜你!成为我的1号备胎")

else:

print("你太丑,你去奥拉克整一下荣")

else:

print("你是个好人,前面右拐是2路汽车,打车回家.")

出题 height

女生找对象

# 男生在1米~1.5米之间 小强 你在哪里?

# 男生在1.5~1.7米之间 没有安全感~

# 男生 1.7~ 1.8米之间 帅哥 留个电话

# 男生 1.8~2米之间 帅哥 你建议多一个女朋友吗

print("<================>")

'''

方法一: python 特有写法:

height = 1.7

if 1 <= height <= 1.5:

print("小强 你在哪里?")

elif 1.5 < height <= 1.7:

print("没有安全感~")

elif 1.7

print("帅哥 留个电话")

elif 1.8 < height <= 2:

print(" 帅哥 你建议多一个女朋友吗")

else:

print("没有符合的条件")

'''

方法二: 通用写法:

height = float( input("请输入您的身高:") )

print(height,type(height) )

if height >= 1 and height <= 1.5:

print("小强 你在哪里?")

elif height>1.5 and height <= 1.7:

print("没有安全感~")

elif height > 1.7 and height <= 1.8:

print("帅哥 留个电话")

elif height > 1.8 and height <= 2:

print(" 帅哥 你建议多一个女朋友吗")

else:

print("没有符合的条件")

上一步 下一步的操作快捷键

ctrl + z

ctrl + y

注释快捷键

ctrl + q notepad

ctrl + / pycharm# ### 多项分支

"""

语法:

if 条件表达式1:

code ...

code ...

elif 条件表达式2:

code ...

code ...

elif 条件表达式3:

code ...

code ...

else:

code ...

code ...

如果条件表达式1成立,就执行1当中的代码块,如果不成立,向下执行

如果条件表达式2成立,就执行2当中的代码块,如果不成立,向下执行

如果条件表达式3成立,就执行3当中的代码块,如果不成立,向下执行

直到最后,没有一个条件满足,直接执行else这个分支;

从多个条件分支当中选1个;

elif 可以是0个也可以是多个

else 可以是0个也可以是1个

"""

youqian = True

双项分支

if youqian == True:

print("我就立刻嫁给你,办手续")

else:

print("你是个好人 ... ")

多项分支

youqian = True

youfang = True

youche = True

youyanzhi = True

youtili = True

if youqian == False:

print("我就嫁给你1")

elif youfang == False:

print("我就嫁给你2")

elif youche == False:

print("我就嫁给你3")

elif youyanzhi == False:

print("我就嫁给你4")

elif youtili == False:

print("我就嫁给你5")

else:

print("你出家吧,当我穿上了婚纱,你也披上了袈裟")

### 巢状分支 (单项分支 双项分支 多项分支的互相嵌套)

if youqian == True:

if youfang == True:

if youche == True:

if youyanzhi == True:

if youtili == False:

print("老娘要嫁给你111")

else:

print("恭喜你!成为我的1号备胎")

else:

print("你太丑,你去奥拉克整一下荣")

else:

print("你是个好人,前面右拐是2路汽车,打车回家.")

出题 height

女生找对象

# 男生在1米~1.5米之间 小强 你在哪里?

# 男生在1.5~1.7米之间 没有安全感~

# 男生 1.7~ 1.8米之间 帅哥 留个电话

# 男生 1.8~2米之间 帅哥 你建议多一个女朋友吗

print("<================>")

'''

方法一: python 特有写法:

height = 1.7

if 1 <= height <= 1.5:

print("小强 你在哪里?")

elif 1.5 < height <= 1.7:

print("没有安全感~")

elif 1.7

print("帅哥 留个电话")

elif 1.8 < height <= 2:

print(" 帅哥 你建议多一个女朋友吗")

else:

print("没有符合的条件")

'''

方法二: 通用写法:

height = float( input("请输入您的身高:") )

print(height,type(height) )

if height >= 1 and height <= 1.5:

print("小强 你在哪里?")

elif height>1.5 and height <= 1.7:

print("没有安全感~")

elif height > 1.7 and height <= 1.8:

print("帅哥 留个电话")

elif height > 1.8 and height <= 2:

print(" 帅哥 你建议多一个女朋友吗")

else:

print("没有符合的条件")

标签:语句,...,elif,python,流程,height,print,else,True

相关文章:

  • 企业微网站建设/品牌营销策划机构
  • 企业微网站建设/品牌营销策划机构