We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I was making it more difficult than it needed to be. I almost threw my computer into the street after I solved the problem with three lines of code.
# Import decimalfromdecimalimportDecimalif__name__=='__main__':n=int(input())student_marks={}for_inrange(n):name,*line=input().split()scores=list(map(float,line))student_marks[name]=scoresquery_name=input()# Extract the values into a list: query_scoresquery_scores=student_marks[query_name]# Sum the scores in the list: total_scorestotal_scores=sum(query_scores)# Convert the floats to decimals and average the scores: avgavg=Decimal(total_scores/3)# Print the mean of the scores, correct to two decimalsprint(round(avg,2))
Finding the percentage
You are viewing a single comment's thread. Return to all comments →
I was making it more difficult than it needed to be. I almost threw my computer into the street after I solved the problem with three lines of code.