Tell us what’s happening:
is this not how it is supposed to be? am I tripping or what
Your code so far
# User Editable Region
details = equation.analyze()
match details:
case {'slope': slope, 'intercept': intercept}:
details_list = [f'slope = {slope:.3f}', f'y-intercept = {intercept:.3f}']
case {'concavity': concavity, 'min_max': (x, y)}:
details_list = [f'concavity = {concavity}', f'min_max = ({x:.3f}, {y:.3f})']
case _:
details_list = []
for detail in details_list:
output_string += detail + '\n'
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15
Challenge Information:
Learn Interfaces by Building an Equation Solver - Step 64
Your case
for the quad_eq should looks exactly like what’s returned for the analyze(self)
function of the class. Look at the linear function analyze(self)
return
, it’s exactly the same.
min_max
should be a variable, not a string.
format concavity = <concavity>
and <min_max> = (<x>, <y>)
, respectively.
See how the instructions show variables in <brackets>
details = equation.analyze()
match details:
case {'slope': slope, 'intercept': intercept}:
details_list = [f'slope = {slope:.3f}', f'y-intercept = {intercept:.3f}']
case {'concavity': concavity, 'min_max': (x, y)}:
details_list = [f'concavity = {concavity}', f'{min_max} = ({x:.3f}, {y:.3f})']
case _:
details_list = []
for detail in details_list:
output_string += detail + '\n'```
I still dont seems to get what your saying about the case?
Look at your linear equation class analyze method:
def analyze(self):
slope, intercept = self.coefficients.values()
return {'slope': slope, 'intercept': intercept}
Look at the return
, it’s exactly the same as your lin eq case:
case {'slope': slope, 'intercept': intercept}:
It should be exactly the same for your quadratic equation.
details = equation.analyze()
match details:
case {'slope': slope, 'intercept': intercept}:
details_list = [f'slope = {slope:.3f}', f'y-intercept = {intercept:.3f}']
case {'x': x, 'y': y, 'min_max': min_max, 'concavity': concavity}:
details_list = [f'concavity = {concavity}',f'{min_max} = ({x:+.3f},{y:+.3f})']
for detail in details_list:
output_string += detail + '\n'
this still is not right however?
It’s more correct now than it was. Pay attention to any hints or errors.
This looks a bit suspicious. You can look to previous parts of code where you were adding to output_string
and try using a similar method.
If you still did not solve this, one error is in: ({x:+.3f},{y:+.3f})
you have to format the output with a clearer separation, try that, also pay attention to the way in which you are formating this, try using this to check your output print(solver(quadr_eq))
. This does not affect the program’s functionality… But it definitely impact the readability. The rest is perfectly hinted by pkdvalis, it is still a problem about format, hope this helps!