用python写用户输入分数,由程序判断分数档次,0-59向屏幕输出不及格,60-79输出及格,80-89输出良好,90-100输出优秀。
时间: 2023-03-31 14:01:09 浏览: 182
你好,根据你的描述,我可以为您提供以下 Python 代码:
score = int(input("请输入分数:"))
if score < 60:
print("不及格")
elif score < 80:
print("及格")
elif score < 90:
print("良好")
else:
print("优秀")
希望能对您有所帮助。
相关问题
从键盘输入分数,输出对应的等级 90--100输出A 80--89输出B 70--79输出C 60--69输出D 60以下输出E
以下是Python代码实现:
```
score = int(input("请输入分数:"))
if score >= 90 and score <= 100:
print("A")
elif score >= 80 and score <= 89:
print("B")
elif score >= 70 and score <= 79:
print("C")
elif score >= 60 and score <= 69:
print("D")
else:
print("E")
```
首先,从键盘输入分数,使用`input()`函数获取用户输入的字符串,然后使用`int()`函数将字符串转换为整数类型。
接着,使用`if-elif-else`语句判断分数所属的等级,并输出相应的等级。注意,每个条件都要使用逻辑运算符`and`连接两个条件,表示分数必须同时满足这两个条件才能输出对应的等级。如果分数不属于以上任何一种情况,输出E级。
用户输入一个学生的成绩,程序输出对应的等级 100 -- 满分 90 -- 99 -- 优秀 70 -- 89 -- 良好 60 -- 69 -- 及格 50 -- 59 -- 较差 0 -- 49 -- 差 其他 -- 分数有误
以下是一个根据学生成绩输出对应等级的Python程序示例:
```python
score = int(input("请输入学生的成绩:"))
if score == 100:
print("满分")
elif score >= 90 and score <= 99:
print("优秀")
elif score >= 70 and score <= 89:
print("良好")
elif score >= 60 and score <= 69:
print("及格")
elif score >= 50 and score <= 59:
print("较差")
elif score >= 0 and score <= 49:
print("差")
else:
print("分数有误")
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)