0 out of 464 challenges solved
Write a Python function `filter_students` that filters students based on their height and weight. The function should take the following inputs: 1. A dictionary where the keys are student names (strings) and the values are tuples containing two floats: the student's height and weight. 2. A minimum height (float). 3. A minimum weight (float). The function should return a dictionary containing only the students who meet or exceed both the minimum height and weight requirements. #### Example Usage ```python [main.nopy] students = { 'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66) } result = filter_students(students, 6.0, 70) print(result) # Output: {'Cierra Vega': (6.2, 70)} result = filter_students(students, 5.9, 67) print(result) # Output: {'Cierra Vega': (6.2, 70), 'Kierra Gentry': (6.0, 68)} ``` #### Constraints - The input dictionary will always have valid data. - Heights and weights are non-negative floats. - The function should not modify the original dictionary.
def filter_students(students, min_height, min_weight): """ Filters students based on minimum height and weight. Args: students (dict): A dictionary with student names as keys and (height, weight) tuples as values. min_height (float): The minimum height requirement. min_weight (float): The minimum weight requirement. Returns: dict: A dictionary of students meeting the height and weight criteria. """ # Initialize the result dictionary result = {} # Iterate through the students dictionary # Add students meeting the criteria to the result dictionary return result