百分制成绩转换五级制
时间: 2024-06-13 07:07:50 浏览: 12
以下是将百分制成绩转换为五级计分制的Python代码:
```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")
```
相关问题
百分制成绩转换五级制c++
这段代码是一个将百分制成绩转换为五级制的C++程序。根据输入的成绩,程序会输出相应的等级,A、B、C、D或E。其中,90分以上为A,80-89分为B,70-79分为C,60-69分为D,60分以下为E。程序使用了switch语句来实现等级的转换,同时也包含了一个default分支,用于处理输入成绩不在0-100范围内的情况。建议在每个case语句组后都加上break语句,以避免出现意外的结果。
以下是一个类似的C++程序,可以实现百分制成绩转换为五级制:
```
#include <iostream>
using namespace std;
int main() {
int score;
cin >> score;
if (score >= 90) {
cout << "A" << endl;
} else if (score >= 80) {
cout << "B" << endl;
} else if (score >= 70) {
cout << "C" << endl;
} else if (score >= 60) {
cout << "D" << endl;
} else {
cout << "E" << endl;
}
return 0;
}
```
c语言将百分制成绩转换为五级值成绩
以下是将百分制成绩转换为五级值成绩的C语言代码:
```c
#include <stdio.h>
int main() {
float score;
printf("请输入百分制成绩:");
scanf("%f", &score);
if (score >= 90) {
printf("成绩等级为:优秀\n");
} else if (score >= 80) {
printf("成绩等级为:良好\n");
} else if (score >= 70) {
printf("成绩等级为:中等\n");
} else if (score >= 60) {
printf("成绩等级为:及格\n");
} else {
printf("成绩等级为:不及格\n");
}
return 0;
}
```
以上代码假设输入的成绩是一个浮点数,根据输入的成绩,使用if-else语句判断成绩等级并输出。如果成绩大于等于90分,则输出"优秀";如果成绩大于等于80分,则输出"良好";如果成绩大于等于70分,则输出"中等";如果成绩大于等于60分,则输出"及格";否则输出"不及格"。
相关推荐
![m](https://img-home.csdnimg.cn/images/20210720083646.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)