-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Mbpp/294
Original requirement:
def max_val(listval: list) -> int:
"""
Write a function to find the maximum value in a given heterogeneous list.
assert max_val(['Python', 3, 2, 4, 5, 'version'])==5
"""
Repaired requirement:
def max_val(listval: list) -> float:
"""
Write a function to find the maximum numeric value in a given heterogeneous list.
The function should:
1. Filter the list to include only numeric types (integers and floating-point values).
2. Compute the maximum value among the filtered numeric elements.
3. Exclude non-numeric types (e.g., strings, booleans) from consideration.
Notes:
- If the list contains both integers and floats, the function should compare them together.
- If the list contains no numeric elements, the function should raise a ValueError.
- The function should return the maximum numeric value as a float, even if the maximum value is an integer.
Example:
assert max_val(['Python', 3, 2, 4, 5, 'version']) == 5.0
assert max_val([3.5, 2.5, 4.5, 5.0]) == 5.0
"""
But I don't understand the hidden test:
Input: ['3.14', False, 7.5]
Expected output: False
My repaired output: 7.5
I feel the hidden test is incorrect.
Metadata
Metadata
Assignees
Labels
No labels