id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

gaurav1780@gmail.com 02_conditions > quadratic_solution
prev  |  next  |  chance

The general form of a quadratic equation is a*x^2 + b*x + c = 0. Define a function that when passed the coefficients a, b and c and a fourth boolean attribute flag, returns, 1. None, if no solution exists; 2. the higher of the two roots of the equation, if flag is True and solution exists; 3. the smaller of the two roots of the equation, if flag is False and solution exists. You can use the built-in max(), min() and math.sqrt() functions. NOTE: The challenge of this question is in the research and not the implementation.


quadratic_solution(1, -3, 2, True) → 2.0
quadratic_solution(1, -3, 2, False) → 1.0
quadratic_solution(1, 10, 24, True) → -4.0

...Save, Compile, Run (ctrl-enter)

def quadratic_solution(a, b, c, flag):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 3 Post-solution available

Copyright Nick Parlante 2017 - privacy