<3>Python开发——条件判断

2021-01-15 12:15

阅读:16794

标签:gen   bsp   条件判断   else   one   int   end   开发   停止   

条件判断

if语句

if else

money = 123
if money > 123:
    print("OK")
else:
    print("No")

if 嵌套

gender = input("??")
if gender == "男":
    age = input("多大")
    if int(age) > 40:
        print("去隔壁")
    else:
        print("请")
    print("激动不已")
else:
    print("滚出去")

while循环

死循环

while True:
  print("!@#$%^&*")

其他循环

示例1:

count = 1
while count 

示例2:

while True:
    content = input("请讲:")
    if content == "Q":
        # break # 打断的是当前本层循环, 终止掉循环
		# exit(0) # 这个是彻底的退出程序。结尾print不会执行
		# continue # 停止当前本次循环。 继续执行下一次循环 暂时性的
    print(content)
print("去吃饭")

 

Python开发——条件判断

标签:gen   bsp   条件判断   else   one   int   end   开发   停止   

原文地址:https://www.cnblogs.com/Wshile/p/12936027.html


评论


亲,登录后才可以留言!