zoukankan      html  css  js  c++  java
  • day04控制流程之if判断

     一.控制流程之if判断

            1、什么是if判断

               判断一个条件如果成立则。。。不成立则。。。

       2、为何要有if判断

           让计算机能够像人一样具有判断能力

       3、如何用if判断

     1 '''
     2 # 语法1:
     3 '''
     4 if 条件1:
     5     code1
     6     code2
     7     code3
     8     ......
     9 '''
    10 # age=18
    11 # if age != 18:
    12 #     print('你好啊小伙子')
    13 #     print('加个微信吧...')
    14 # print('other code...')
    15 
    16 # 语法2:
    17 '''
    18 if 条件:
    19     code1
    20     code2
    21     code3
    22     ......
    23 else:
    24     code1
    25     code2
    26     code3
    27     ......
    28 '''
    29 # age=18
    30 # sex='male'
    31 # wuzhong='human'
    32 # is_beautiful=True
    33 #
    34 # if age > 16 and age < 22 and sex == 'female' and 
    35 #         wuzhong == 'human' and is_beautiful:
    36 #     print('开始表白...')
    37 # else:
    38 #     print('阿姨好,我逗你玩呢...')
    39 
    40 
    41 # 语法3:
    42 '''
    43 if 条件1:
    44     if 条件2:
    45         code1
    46         code2
    47         code3
    48     code2
    49     code3
    50     ......
    51 '''
    52 # age = 18
    53 # sex = 'female'
    54 # wuzhong = 'human'
    55 # is_beautiful = True
    56 # is_successful = True
    57 #
    58 # if age > 16 and age < 22 and sex == 'female' and wuzhong == 'human' and is_beautiful:
    59 #     print('开始表白...')
    60 #     if is_successful:
    61 #         print('在一起')
    62 #     else:
    63 #         print('阿姨再见....')
    64 # else:
    65 #     print('阿姨好,我逗你玩呢...')
    66 
    67 # 语法4:
    68 '''
    69 if 条件1:
    70     子代码块1
    71 elif 条件2:
    72     子代码块2
    73 elif 条件3:
    74     子代码块3
    75 elif 条件4:
    76     子代码块4
    77 .........
    78 else:
    79     子代码块5
    80 '''
    81 
    82 score = input('your score>>: ')
    83 score=int(score)
    84 if score >= 90:
    85     print('优秀')
    86 elif score >= 80:
    87     print('良好')
    88 elif score >= 70:
    89     print('普通')
    90 else:
    91     print('很差')
  • 相关阅读:
    JPG bufffer转Mat
    cv:Mat MFC上显示 BitMatToWnd
    opencv 版本修改
    2个多边形的关系判断和相交面积计算
    截取图像 opencv
    SQL Server 存储过程的分页方案比拼
    XP系统下数据库文件夹的权限设置
    关于23种设计模式的有趣见解
    一些编程的好习惯
    sql server 2000的数据库还原
  • 原文地址:https://www.cnblogs.com/frank007/p/9647184.html
Copyright © 2011-2022 走看看