输入一个等级制的成绩,经判断后输出该等级的对应成绩。其中,90分以 上为“A”,80~89分为“B”,70~79分为“C”,60~69分为“D”,60分以下为“E”。
时间: 2023-10-04 08:08:30 浏览: 229
好的,我可以为您写一个简单的程序来实现该功能。以下是Python代码示例:
```python
score = int(input("请输入成绩:"))
if score >= 90:
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")
```
您可以将该代码复制到您的Python环境中运行,并按照提示输入成绩,程序会输出对应的等级。
相关问题
输入一个等级制成绩,判断后输出对应成绩输出对应成绩,python
可以使用if语句来判断成绩等级,并输出对应成绩。以下是一个简单的Python代码示例:
```
score = int(input("请输入成绩:"))
if score >= 90:
print("成绩等级为:A")
elif score >= 80:
print("成绩等级为:B")
elif score >= 70:
print("成绩等级为:C")
elif score >= 60:
print("成绩等级为:D")
else:
print("成绩等级为:E")
```
代码中,首先使用`input()`函数获取用户输入的成绩,并使用`int()`函数将输入的字符串转换为整数类型。然后使用if语句进行条件判断,根据不同的成绩等级输出对应的等级。注意,if语句的条件是从高到低判断,因为如果成绩等级为A,则不需要再判断是否符合B、C、D、E等级的条件。
输入一个等级制成绩,判断后输出对应成绩输出对应成绩,python if else语句
可以使用if-else语句来判断成绩等级,并输出对应成绩。以下是一个简单的Python代码示例:
```
score = int(input("请输入成绩:"))
if score >= 90:
print("成绩等级为:A")
else:
if score >= 80:
print("成绩等级为:B")
else:
if score >= 70:
print("成绩等级为:C")
else:
if score >= 60:
print("成绩等级为:D")
else:
print("成绩等级为:E")
```
代码中,首先使用`input()`函数获取用户输入的成绩,并使用`int()`函数将输入的字符串转换为整数类型。然后使用if-else语句进行条件判断,根据不同的成绩等级输出对应的等级。注意,if-else语句的嵌套层数较多,代码可读性不如前面使用if-elif语句的示例。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_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)