luck_purple 2021-12-29 15:31 采纳率: 100%
浏览 22
已结题

请问这一题应该如何做,刚学Python

【问题描述】输入若干成绩值,以回车作为输入结束。输出最高的三个成绩值,以及最大值和最小值。
【输入形式】"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

```

  • 写回答

2条回答 默认 最新

  • 陈年椰子 2021-12-29 17:34
    关注
    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]))
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 1月6日
  • 已采纳回答 12月29日
  • 修改了问题 12月29日
  • 创建了问题 12月29日

悬赏问题

  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi