From a6e6a4d0c6d89f43ed4d1d07b3e6e8bd571178d6 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 8 Sep 2025 11:52:21 +0800 Subject: [PATCH] =?UTF-8?q?09-08-=E5=91=A8=E4=B8=80=5F11-52-21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 01.基础语法/01.python基础.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/01.基础语法/01.python基础.md b/01.基础语法/01.python基础.md index ebd6b74..f6ab755 100644 --- a/01.基础语法/01.python基础.md +++ b/01.基础语法/01.python基础.md @@ -563,6 +563,31 @@ else: 上面所有的条件不满足就走这段 ``` +- 判断分数和对应的评价 + +```python +score = input("你考了多少分(满分100):") +# 判断输入的内容全部是数字组成 +if score.isdigit(): + # 转换数据类型,将score转换为整数型 + score = int(score) + if score <= 100 and score >= 0: + if score >= 90: + print("优秀") + elif score >= 80: + print("良好") + elif score >= 60: + print("及格") + else: + print("不及格") + else: + print("你输入的数字不对!") +else: + print("请输入分数") +``` + + + ## 流程控制之 --while 基本循环