By the end of this task, you will be able to identify conditions and implement
conditional logic with confidence. You’ll learn how to interpret and analyze
flowcharts that use conditional statements, allowing you to predict outcomes
based on different inputs. Additionally, you’ll develop the skills to debug
control statements, ensuring that the logic in your programs or spreadsheets
accurately reflects the decisions you intend to make.
In programming, you will often need your program to make decisions based on the
conditions it is given. You can tell your programs when to make decisions by
writing conditional statements into your program or spreadsheet. Conditional
statements check if a condition is either True or False and then perform actions
based on the outcome.
You are given the task of writing a program that finds the real roots of a
quadratic function of the form \(f(x) = ax^2 + bx + c\). Recall from
algebra that there are three possible values for the number of real roots
of a quadratic function depending on the value of the discriminant
\((b^2 - 4ac)\).
Create a flow chart for a program that takes \(a\), \(b\), and
\(c\) as inputs, uses conditional statements with the discriminant to
determine how many real roots there are, and prints the value of the
root(s).
For \(ax^2 + bx + c =0\), where \(a\), \(b\) and \(c\) are real numbers, the discriminant, is the expression under the radical in the quadratic formula: \(b^2 - 4ac\) . It tells us whether the solutions are real numbers or complex numbers and how many solutions of each type to expect.