第一种:
info = list()
money = 0
ans = 0
total = 0
for i in range(int(input())):
info = list(input().split(" "))
if int(info[1])>80 and int(info[5])>=1:
money+=8000
if int(info[1])>85 and int(info[2])>80:
money+=4000
if int(info[1])>90:
money+=2000
if int(info[1])>85 and info[4]=='Y':
money+=1000
if int(info[2])>80 and info[3]=='Y':
money+=850
if money > ans:
ans = money
name = info[0]
total+=money
money = 0
print(name)
print(ans)
print(total)
第二种:
def optiontobool(ch, yes='Y', no='N'):
if ch == yes:
return True
elif ch == no:
return False
class Student:
def __init__(self,
name: str,
qm: int,
bj: int,
gb,
xb,
lw: int,
yes='Y',
no='N'):
self.name = name
self.qm = qm
self.bj = bj
if type(gb) == bool:
self.gb = gb
else:
self.gb = optiontobool(gb, yes, no)
if type(xb) == bool:
self.xb = xb
else:
self.xb = optiontobool(xb, yes, no)
self.lw = lw
self.jxj = self.getjxj()
def getjxj(self):
jxj = 0
if self.qm > 80 and self.lw > 0:
jxj += 8000
if self.qm > 85 and self.bj > 80:
jxj += 4000
if self.qm > 90:
jxj += 2000
if self.qm > 85 and self.xb:
jxj += 1000
if self.bj > 80 and self.gb:
jxj += 850
return jxj
def main():
n = int(input())
stu = []
tot_money = 0
data = input().split()
data[1] = int(data[1])
data[2] = int(data[2])
data[5] = int(data[5])
stu.append(Student(*data))
stu_max = stu[0]
stu_index = 0
tot_money += stu[0].jxj
for i in range(1, n):
data = input().split()
data[1] = int(data[1])
data[2] = int(data[2])
data[5] = int(data[5])
stu.append(Student(*data))
if stu[i].jxj > stu_max.jxj:
stu_max = stu[i]
stu_index = i
tot_money += stu[i].jxj
print(stu_max.name)
print(stu_max.jxj)
print(tot_money)
if __name__ == '__main__':
main()
大家借鉴。