Python概述







第二章-Python基础语法
01-字面量
02-注释
03-变量
04-数据类型
05-数据类型转换

06-标识符
07-运算符
08-字符串的三种定义方式
09-字符串的拼接
10-字符串格式化
11-字符串格式化的精度控制
12-字符串格式化的方式-快速写法
13-对表达式进行格式化
14-字符串格式化练习题讲解


15-数据输入(input语句)写入什么都当成string类型
第三章-python判断语句
01-布尔类型和比较运算符
02-if语句的基本格式
03-案例-成年人判断讲解
04-if else组合判断语句


05-案例-我要买票吗讲解
06-if elif else组合使用的语法


07-案例-猜猜心里数字讲解
08-判断语句的嵌套
09-判断语句综合案例
import random
num=random.randint(1,10)
first=int(input("请输入你的猜测:"))
if first!=num:
if first<num:
print("猜测小了")
else:
print("猜测大了")
second = int(input("请输入你的第二次猜测:"))
if second != num:
if second < num:
print("猜测小了")
else:
print("猜测大了")
third = int(input("请输入你的第三次猜测:"))
if third != num:
if third < num:
print("猜测小了")
else:
print("猜测大了")
else:
print("第三次猜测对了")
else:
print("第二次猜测对了")
else:
print("猜测对了")
代码一样只不过,if-else顺序不一样