Question: * * Question: * * A computer science department is developing a program to assign students to study groups based on their grades and interests.
Question:
A computer science department is developing a program to assign students to study groups based on their grades and interests. You are tasked with creating a function in Python that will:
Accept a list of students, where each student is represented by a dictionary containing their namegrade and interest fields. For example:
python
students
name: "Alice", "grade": "interest": AI
name: "Bob", "grade": "interest": "Data Science"
name: "Charlie", "grade": "interest": AI
name: "Diana", "grade": "interest": "Cybersecurity"
name: "Eve", "grade": "interest": "Data Science"
Sort students by their grade in descending order. In case of a tie in grades, further sort by their interest alphabetically.
Group students with the same grade and interest together, and return the groups as a list of lists. Each inner list should represent a unique group of students with the same grade and interest.
Function Signature:
python
def groupstudentsstudents: list list:
# Your code here
Sample Input:
python
students
name: "Alice", "grade": "interest": AI
name: "Bob", "grade": "interest": "Data Science"
name: "Charlie", "grade": "interest": AI
name: "Diana", "grade": "interest": "Cybersecurity"
name: "Eve", "grade": "interest": "Data Science"
Sample Output:
python
name: "Diana", "grade": "interest": "Cybersecurity"
name: "Bob", "grade": "interest": "Data Science"
name: "Alice", "grade": "interest": AI
name: "Eve", "grade": "interest": "Data Science"
name: "Charlie", "grade": "interest": AI
Explanation:
The function organizes students first by grades in descending order and then groups them by their interests where applicable.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
