Sort by

recency

|

3765 Discussions

|

  • + 0 comments

    if name == 'main': n = int(input()) student_marks = {} for _ in range(n): name, *line = input().split() scores = list(map(float, line)) student_marks[name] = scores query_name = input()

    marks=student_marks.get(query_name)
    sum_marks=0
    count_num=0
    for i in marks:
        sum_marks+=i
        count_num+=1
    avg_marks=(sum_marks/count_num)
    print("{:.2f}".format(avg_marks))
    
  • + 0 comments

    if name == 'main': n = int(input()) student_marks = {} for _ in range(n): name, *line = input().split() scores = list(map(float, line)) student_marks[name] = scores query_name = input()

    score = list(student_marks.get(query_name,[]))
    avg_score = sum(score)/len(score) if score else 0
    print(f'{avg_score:.2f}')
    
  • + 0 comments

    if name == 'main': n = int(input()) student_marks = {} for _ in range(n): name, *line = input().split() scores = list(map(float, line)) student_marks[name] = scores query_name = input() num=[] sum=0

    for i,j in student_marks.items():
        if i==query_name:
            num=j
            count=len(j)
            for k in num:
                sum+=k
    val=(sum/count)
    print(f'{val:.2f}')
    
  • + 0 comments
    if __name__ == '__main__':
        n = int(input())
        student_marks = {}
        for _ in range(n):
            name, *line = input().split()
            scores = list(map(float, line))
            student_marks[name] = scores
        query_name = input()
        Marks=student_marks[query_name]
        avg=sum(Marks)/len(Marks)
        print(f"{avg:.2f}")
    
  • + 0 comments
    if __name__ == '__main__':
        n = int(input())
        student_marks = {}
        for _ in range(n):
            name, *line = input().split()
            scores = list(map(float, line))
            student_marks[name] = scores
        query_name = input()
    
    # initiate the accumulators to store total marks
    # and average scores
    total_marks = 0
    avg_score = 0
    # get each name in student marks
    for name in student_marks:
        # when name is equal to query name
        if name == query_name:
            # add the scores in the list for query student
            for score in student_marks[name]:
                total_marks += score
            # find its average
            avg_score = total_marks/len(student_marks[name])
    
    print("{:.2f}".format(avg_score))