Define a function first_over(threshold, values) that returns the first value in values greater than
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
Problem
Define a function first_over(threshold, values) that returns the first value in values greater than threshold, or -1 if none qualify. Use a for loop with early return. Print first_over(50, [12, 27, 44, 58, 73]) and first_over(100, [1, 2, 3]) on separate lines.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.