Question: ENGR 1 2 0 4 Programming Languages in EngineeringLab 1 2 Python Implementation of MATLAB Lab 2 Note: For all labs and assignments copy and
ENGR Programming Languages in EngineeringLab Python Implementation of MATLAB Lab Note: For all labs and assignments copy and paste into a Word file your program script file the relevant command window and plots if applicable. Try to condense the printout as best as possible. Convert the MATLAB program on the reverse side to a PYTHON program py script file to use the quadratic formula to solve for the roots of the equation a x b x c Recall there are three cases, depending on the value of the discriminant disc b a c Set up your program to allow you to enter numerical values for the coefficients a b and cUse nested ifelse selection statements to display one of the three messages below, followed by the solution for the roots: Two real roots exist. Double equal root exists. Two complex conjugate roots exist. Note that if the roots are complex, PYTHON will automatically display them in complex form using j the unit imaginary quantity equivalent to i A sample output is shown below: Enter a: Enter b: Enter c: Two complex conjugate roots exist.x j and x j Run your program for the three cases shown: a b c a b c a b c Lab MATLAB Solution to Quadratic Equation a xbx c Enter quadratic equation coefficients.a inputEnter a: ;b inputEnter b: ;c inputEnter c: ; Determine nature of the roots.disc b a c;if disc dispTwo real roots exist.elseif disc dispTwo complex conjugate roots exist.else dispDouble real root exists.end Calculate and display the roots.dispThe roots are: x b sqrtdisc ax b sqrtdisc a Note: For Python, to display the roots as shown in the sample output, remove the line dispThe roots are: Then, calculate x and x and display the results by adding the statement below: print x: f and x: fformatx x
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
