Skip to content

11 #21

Description

@legend17-dot

Function to calculate average marks

def calculate_average(students):
total = sum(student["marks"] for student in students)
return total / len(students)

Function to find topper

def find_topper(students):
return max(students, key=lambda x: x["marks"])

Function to display report

def display_report(students):
print("\n--- Student Report ---")
for student in students:
print(f"{student['name']} : {student['marks']}")
avg = calculate_average(students)
topper = find_topper(students)
print("\nClass Average:", avg)
print("Topper:", topper["name"], "-", topper["marks"])

Main Program

n = int(input("Enter number of students: "))
students = []
for i in range(n):
name = input(f"Enter name of student {i+1}: ")
marks = float(input(f"Enter marks of {name}: "))
students.append({"name": name, "marks": marks})

Display summary

display_report(students)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions