蓝桥杯 成绩统计
小蓝给学生们组织了一场考试,卷面总分为 100 分,每个学生的得分都是一个 0 到 100 的整数。
如果得分至少是 60 分,则称为及格。如果得分至少为 85 分,则称为优秀。
请计算及格率和优秀率,用百分数表示,百分号前的部分四舍五入保留整 数。
输入描述
输入的第一行包含一个整数 n,表示考试人数。
接下来 n 行,每行包含一个 0 至 100 的整数,表示一个学生的得分。
输出描述
输出两行,每行一个百分数,分别表示及格率和优秀率。百分号前的部分 四舍五入保留整数。
输入输出样例
示例
输入
7
80
92
56
74
88
100
0
输出
71%
43%
方案一
避开向数组传值,来一个判断一个
num= int(input())
excellent = 0
normal = 0
for i in range(num):
score = int(input())
if score >= 85:
excellent += 1
normal += 1
elif score >= 60:
normal += 1
print("{:.0f}%".format((excellent*100) / num))
print("{:.0f}%".format((normal*100) / num))
方案二
先向数组传值,一个一个判断
num= int(input())
a = [int(input()) for n in range(num)]
excellent = 0
normal = 0
for i in range(num):
if a[i] >= 85:
excellent += 1
normal += 1
elif a[i] >= 60:
normal += 1
print("{:.0f}%".format((excellent*100) / num))
print("{:.0f}%".format((normal*100) / num))