Python每日练习

Python每日练习_第1张图片

 

Python每日练习_第2张图片 

 

#计算机挑战赛--学科竞赛
people = int(input('输入想要参赛的人数:\n'))
subject = input('想要参加选拔的科目:\n')
list = [];total = 0;marks = [];
for i in range(people):
    id,g1,g2,g3,g4,g5,g6 = map(int,input().split())
    list.extend([[id,g1,g2,g3,g4,g5,g6]])
if subject == 'I':
    for i in range(people):
        List = list[i]
        x = List[2]
        y = List[3]
        new_total = x + y
        marks.append(new_total)
    count = marks.count(max(marks))
    if count == 1:
        List1 = list[marks.index(max(marks))]
        print(List1[0])
    else:
        List3 = []
        position = [index for index,value in enumerate(marks) if value == max(marks)]
        print(position)
        for i in position:
            List2 = list[i]
            List3.append(List2[0])
        List3.sort()
        print(List3)
        for i in List3:
            print(i)
if subject == 'B':
    for i in range(people):
        List = list[i]
        x = List[2]
        y = List[4]
        new_total = x + y
        marks.append(new_total)
    count = marks.count(max(marks))
    if count == 1:
        List1 = list[marks.index(max(marks))]
        print(List1[0])
    else:
        List3 = []
        position = [index for index,value in enumerate(marks) if value == max(marks)]
        for i in position:
            List2 = list[i]
            List3.append(List2[0])
        List3.sort()
        for i in List3:
            print(i)
if subject == 'H':
    for i in range(people):
        List = list[i]
        x = List[5]
        y = List[6]
        new_total = x + y
        marks.append(new_total)
    count = marks.count(max(marks))
    if count == 1:
        List1 = list[marks.index(max(marks))]
        print(List1[0])
    else:
        List3 = []
        position = [index for index,value in enumerate(marks) if value == max(marks)]
        for i in position:
            List2 = list[i]
            List3.append(List2[0])
        List3.sort()
        for i in List3:
            print(i)

 

你可能感兴趣的:(python,笔记)