日记_20191222

class Person:

def __init__(self, firstName, lastName, idNumber):

self.firstName = firstName

self.lastName = lastName

self.idNumber = idNumber

def printPerson(self):

print("Name:", self.lastName +",", self.firstName)

print("ID:", self.idNumber)

class Student(Person):

# Class Constructor

#

#  Parameters:

#  firstName - A string denoting the Person's first name.

#  lastName - A string denoting the Person's last name.

#  id - An integer denoting the Person's ID number.

#  scores - An array of integers denoting the Person's test scores.

#

# Write your constructor here

#  Function Name: calculate

#  Return: A character denoting the grade.

#

# Write your function here

    def __init__(self, firstName, lastName, idNumber, scores):

super().__init__(firstName, lastName, idNumber)

self.scores = scores

def calculate(self):

avg=sum(self.scores)/len(self.scores)

if (avg>=90 and avg<=100):

return 'O'

        elif (avg>=80 and avg<90):

return 'E'

        elif (avg>=70 and avg<80):

return 'A'

        elif (avg>=55 and avg<70):

return 'P'

        elif (avg>=40 and avg<55):

return 'D'

        elif avg<40:

return 'T'

line =input().split()

firstName = line[0]

lastName = line[1]

idNum = line[2]

numScores =int(input())# not needed for Python

scores =list(map(int, input().split()))

s = Student(firstName, lastName, idNum, scores)

s.printPerson()

print("Grade:", s.calculate())

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 8月22日-----字符串相关 2-3 个性化消息: 将用户的姓名存到一个变量中,并向该用户显示一条消息。显示的消...
    future_d180阅读 1,023评论 0 1
  • 写在前面的话 代码中的# > 表示的是输出结果 输入 使用input()函数 用法 注意input函数输出的均是字...
    FlyingLittlePG阅读 3,170评论 0 9
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,672评论 0 10
  • 本文是对 MagicalRecord github上的翻译 正文:注意: MagicalRecord 在 ARC...
    騂跃神话阅读 2,118评论 1 5
  • 1.数据库简介 人类在进化的过程中,创造了数字、文字、符号等来进行数据的记录,但是承受着认知能力和创造能力的提升,...
    大熊_7d48阅读 600评论 0 1

友情链接更多精彩内容