zoukankan      html  css  js  c++  java
  • 第4天python学习 条件和 循环语句

    一、条件语句:

    1、if基本语句

    if  条件 :

      代码块

    else:

      代码块

    print(".......")

    2、if 支持嵌套

     #!/user/bin/env python

    if 1 == 1:
    if 2 == 2:
    print("收到")
    else:
    print("没有收到")
    else:
    print("good")
    3、if   elif

     inp=input("请输入会员级别:")

    if inp=="高级会员":
    print("送茅台1瓶")
    elif inp=="铂金会员":
    print("送五星茅台1瓶")
    elif inp=="白金会员":
    print("五粮液1瓶")
    else:
    print("价值100的红酒1瓶")

    备注:

    1、1==1不想输出任何东西

    if 1==1:

      psss——表示不执行:过

    else:

    print("正确")

    2、代码是按顺序执行;

    3、准确注意同一级别代码。

    二、 while语句

    死循环:

    while 1==1:

      print("ok")

    while循环:

    count = 0
    while count< 10:
      print(count)
      count=count+1
    print("不在进行累加")

    补充:

    1、while  else语句;

    2、while  continue /break      continue:表示终止当前循环,,开始下一次循环;break:表示终止所有循环




  • 相关阅读:
    ubuntu后台运行命令
    jquery获取焦点位于的元素
    thymeleaf 处理模板为字符串
    以字符串形式获取excel单元格中的内容
    ajax 上传文件
    springboot logback
    javaService
    Assistant For Chess Cards
    E生活
    易兼职-找工作兼职平台
  • 原文地址:https://www.cnblogs.com/jianchixuexu/p/11407120.html
Copyright © 2011-2022 走看看