zoukankan      html  css  js  c++  java
  • 总分最高的学生姓名和各科成绩

    题目

    代码

    class Student:
        def __init__(self, sname, mscore, cscore, escore):
            self.sname = sname
            self.mscore = mscore
            self.cscore = cscore
            self.escore = escore
        def total(self):
            return  self.mscore + self.cscore + self.escore 
    
    def FindMaxScoreStudent(sname,mscore,cscore,escore):
        students = []
        total = []
        for i in range(len(sname)):
            students.append( Student(sname[i], mscore[i], cscore[i], escore[i]))
            total.append(students[i].total())
        student = students[total.index(max(total))]
        return student
    
    sname = list(map(str,input("Enter sname:
    ").split( )))
    mscore = list(map(int,input("Enter mscore:
    ").split( )))
    cscore = list(map(int,input("Enter cscore:
    ").split( )))
    escore = list(map(int,input("Enter escore:
    ").split( )))
    student =  FindMaxScoreStudent(sname,mscore,cscore,escore)
    print(student.sname + ' ' + str(student.mscore) + ' ' + str(student.cscore) + ' ' + str(student.escore)) 
    

    输入

    Enter sname:
    jack tom
    Enter mscore:
    95 84
    Enter cscore:
    90 75
    Enter escore:
    85 90
    

    输出

    jack 95 90 85

  • 相关阅读:
    Linux命令——mkdir
    UNIX 高手的 10 个习惯
    Linux命令——pwd
    Linux命令——cd命令
    Linux命令——ls命令
    denyhost安装脚本
    三台服务器无需密码相互访问
    字符串方法
    nginx简易安装
    shell 条件判断语句整理
  • 原文地址:https://www.cnblogs.com/sinlearn/p/12830693.html
Copyright © 2011-2022 走看看