Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1 . Quadratic Equations plz identify what it problem 1 and what is problem 2 this is in python thankyou A quadratic equation has
Problem Quadratic Equations plz identify what it problem and what is problem this is in python thankyou
A quadratic equation has the form:
a x b x c
The two solutions called roots are given by the formula:
x bpm b a c
a
Write a program with a loop that :
a solves quadratic equations with coefficients read from the terminal,
b visualizes the corresponding quadratic function y ax
bx c using the matplotlib.pyplot module
replacing module pylab used in the book
Details:
The program consists of a main while loop an infinite loop in which the user is prompted to enter
values for coefficients a b and c Assume the user types valid float numbers from the terminal. The
program converts the input to float type and then uses formula above to compute solutions x and
x as follows:
if b ac then the solutions are complex numbers ie not real and the program displays
the string no real solutions
if b ac then xx and the program displays: one solution: followed by the value x
if b ac then the solutions are distinct and the program displays two solutions:
followed by the values of x and x
To keep the problem simple we can assume that the user never enters a value for coefficient a that is
equal to
To stop the loop and end the program the user just types the ENTER key instead of the string for
coefficient a
Within the main loop, after printing the values of the real solutions if any to the terminal the
program displays the graphic of the quadratic function y ax
bx c using the matplotlib.pyplot
module. The chart should use points.
If the function has real roots one or two make sure the roots are visible on the chart. Eg if the
roots are and use a domain interval for values x on the x axis that includes and like
If the function has no real roots, then center the function domain x values on the functions
minimum or maximum value, which is x opt b
a
Pick your own approach to select the functions domain while complying with the above
requirements.
Insert the source code from ppy into the hdoc Word document. The grader appreciates if you
use syntax highlighting, although it is not required.
Take a screenshot of the PC desktop showing the Spyder Python shell and the matplotlib figure
window and paste it in the hdoc file after the source code.
The screenshot may look similar to this one:
Here is a sample user session on the terminal:
Problem Pythagorean Numbers
The lengths abc of the three sides of a right triangle are related by this wellknown formula:
a b c
A Pythagorean triple consists of three positive integer numbers bound by the above relation. An
example of a triple is
Enter a:
Enter b:
Enter c:
one solution:
Enter a:
Enter b:
Enter c:
no real solutions
Enter a:
Enter b:
Enter c:
two solutions: x x
user types CTRLZ on Windows to enter EOF and finish the program
Write program ppy that reads from the terminal a positive integer n and that computes and
displays to the terminal all possible Pythagorean triples abc where
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started