【问题描述】输入若干成绩值,以回车作为输入结束。输出最高的三个成绩值,以及最大值和最小值。
【输入形式】"Input a score(end of enter):"
【输出形式】"Top 3 scores:" "max={},min={}"
【输入输出示例】
```python
Input a score(end of enter):9
Input a score(end of enter):4.6
Input a score(end of enter):8.2
Input a score(end of enter):1
Input a score(end of enter):4
Input a score(end of enter):7
Input a score(end of enter):
Top 3 scores:
9
8.2
7
max=9,min=1
```
s_lst = []
while True:
s = input("Input a score(end of enter):")
if s == "":
break
else:
s_lst.append(float(s))
for i in range(len(s_lst)):
if int(s_lst[i]) == s_lst[i]:
s_lst[i] = int(s_lst[i])
# print(s_lst)
s_lst.sort(reverse=True)
print("Top 3 scores:")
for s in s_lst[:3]:
print(s)
print("max={},min={}".format(s_lst[0],s_lst[-1]))
s_lst = []
while True:
s = input("Input a score(end of enter):")
if s == "":
break
else:
s_lst.append(float(s))
print(s_lst)
s_lst.sort(reverse=True)
print("Top 3 scores:")
for s in s_lst[:3]:
print(s)
print("max={},min={}".format(s_lst[0],s_lst[-1]))