Project 6: Rating Curve Root Finder
Scientific Computing
Builds on these lessons
Current Task
Objective
root_scalar() finds where a function crosses zero within a bracketed interval — useful whenever you need to solve f(x) = 0.
Task: find the root of a simple function within [0, 5] and print it.
index.py
from scipy.optimize import root_scalar
def rating_curve(x):
return x ** 2 - 4
result = root_scalar(rating_curve, bracket=[0, 5])
print(result.root)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview