• + 0 comments

    Sure, here's a short solution for the problem "Finding the percentage":

    Problem: Given a dictionary containing student names and their corresponding scores in a subject, find the percentage score of a specific student.

    Solution:

    python Copy code def find_percentage(student_scores, student_name): if student_name in student_scores: total_score = sum(student_scores[student_name]) num_subjects = len(student_scores[student_name]) percentage = total_score / num_subjects return percentage else: return f"Student '{student_name}' not found."

    Example usage:

    student_scores = { 'Alice': [85, 90, 78], 'Bob': [92, 88, 95], 'Charlie': [78, 85, 80] }

    name = 'Asia Alice' result = find_percentage(student_scores, name) print(f"{name}'s percentage: {result}%") This solution defines a function find_percentage that takes a dictionary student_scores and a student_name as input. It calculates the total score of the student and divides it by the number of subjects to find the percentage. If the given student name is not found in the dictionary, it returns an appropriate message indicating that the student was not found. The example usage demonstrates how to use the function with sample data.