用键盘输入学生成绩,90以上输出“优秀”,80-90输出“良好”,70-80输出“中间”,60-70输出“及格”,60以下输出“不及格”
时间: 2023-08-21 15:01:38 浏览: 182
你可以使用以下Python代码实现:
```
score = int(input("请输入学生成绩:"))
if score >= 90:
print("优秀")
elif score >= 80:
print("良好")
elif score >= 70:
print("中间")
elif score >= 60:
print("及格")
else:
print("不及格")
```
在这个代码中,我们首先使用 `input()` 函数获取用户输入的成绩并将其转换为整型。然后,使用 `if-elif-else` 条件语句根据成绩输出相应的评价。
相关问题
从键盘输入分数,输出对应的等级 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级。
C语言从键盘中输入8个学生的成绩,计算输出成绩优秀(成绩≥90)的学生比例
此问题属于计算机问题,可以回答。
假设输入的8个学生成绩存储在一个数组中,可以遍历数组并统计成绩大于等于90的学生人数。最后将该人数除以8,即可得到成绩优秀的学生比例。
代码示例:
```c
#include <stdio.h>
int main() {
int grades[8];
int i, count = 0;
printf("请输入8个学生的成绩:\n");
for (i = 0; i < 8; i++) {
scanf("%d", &grades[i]);
if (grades[i] >= 90) {
count++;
}
}
printf("成绩优秀的学生比例为:%.2f%%\n", (float)count / 8 * 100);
return 0;
}
```
输入样例:
```
请输入8个学生的成绩:
80 90 85 95 70 75 92 88
```
输出样例:
```
成绩优秀的学生比例为:37.50%
```
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.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)