一.if判断: 语法一: if 条件: # 条件成立时执行的子代码块 代码1 代码2 代码3 示例: sex='female' age=18 is_beautiful=True if sex == 'female' and age > 16 and age < 20 and is_beautiful: print('开始表白...') print('other code1...') print('other code2...') print('other code3...') 示例 语法二:…
一.什么是表达式 表达式(Expression)是运算符(operator)和操作数(operand)所构成的序列 二.表达式的优先级 三.表达式优先级练习 优先级同级 从左往右计算 1 or 2 and 3 返回1 not 1 or 2 +2 ==c 返回 False 等价于(not 1) or ((2 +2) ==c) print(1 or 3) # 1 or 运算 计算机只需要判断1 即可 print(1 and 3) # 3 and 运算 计算机要判断1后再判断3 所以返回3 四.在文本…
条件判断经常使用if语句进行判断,表达方式为:if 条件语句: :elif:else if...用于执行第一条不满足if的判断,继续执行其它的判断.比如一个简单的if判断 Python3取消了raw_input(),使用input()接受输入,如果需要,在input()前加上限定条件int or float,默认str不用添加. score = int(input('input your score')) if num >= 80: print("excellllent!&quo…