Answer:
see explaination
Step-by-step explanation:
# importing "collections" for namedtuple()
from collections import namedtuple
# function creates student records and return the named tuple
def create_student():
Student = namedtuple('Student',['name','exam1','exam2']) # creating the object Student
# taking input the name and scores of the students
name = input()
exam1 = float(input())
exam2 = float(input())
return Student(name, exam1, exam2) # return the named tuple
# function creates list of student records and return it
def create_class(n):
student_list = []
# creating student data for n students
for i in range(n):
student_list.append(create_student()) # storing data in the student_list
return student_list # return the student data i.e. student_list
# function calculates the final score of each student and returns it
def calculate_score(S):
final_score = 0
if S[1] > S[2]: # if exam1 score is greater than exam2
final_score = S[1] * 0.3 + S[2] * 0.7 # final score is sum of 30% of exam1 and 70% exam2
elif S[1] < S[2]: # if exam2 score is greater than exam1
final_score = S[1] * 0.7 + S[2] * 0.3 # final score is sum of 30% of exam2 and 70% exam1
elif S[1] == S[2]: # if both scores are equal
final_score = S[1] # final score is sum if 30% of exam1 and 70% exam2, but here both scores are equal so final score is equal to any one of the score
else: # if scores are invalid
print('Invalid entries')
return final_score # return final score
# driver function
def main():
n = int(input()) # enter the no. of students in class
if n < 1: # if n is less than 1 return nothing and stop execution
return
student_list = create_class(n) # call create_class to create class of n students
for i in student_list:
print(round(calculate_score(i), 2)) # calculate the final score for each student and print it
if __name__ == "__main__": main()