酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

现在有一组学生的成绩,将他们分为不及格成绩<60和及格成绩>=60两组,分别输出。

以下是使用 Python 语言来实现这个功能的示例代码: ```python # 假设这组学生成绩存储在一个列表中 student_scores = [50, 70, 85, 45, 60, 90, 30, 55] # 初始化两个空列表来存储不及格和及格的成绩 failed_scores = [] passed_scores = [] # 遍历成绩列表进行分组 for score in student_scores: if score < 60: failed_scores.append(score) else: passed_scores.append(score) # 输出不及格的成绩 print("不及格的成绩:", failed_scores) # 输出及格的成绩 print("及格的成绩:", passed_scores) ``` 您可以根据实际情况修改`student_scores`列表中的成绩数据。如果您需要使用其他编程语言来实现,或者有其他特定的要求,请随时告诉我。 [2024-10-30 21:38:21 | AI写代码神器 | 207点数解答]

相关提问