Quadratic.py
Problem
You need to create a program that outputs a quadratic in standard form given two user-inputted roots.
You are not allowed to use outside libraries. This is to test your problem solving skills!
Example
> first root: foo
> Give me an integer please!
> first root: 2
> second root: -2
> x^2-4
The user tried to input a non-integer, so the program prompts the user to try again.
The user then inputs 2 and -2 for the two roots, which correspond to (x+2) and (x-2).
Distributing those two gets us x^2-4.
An output of x^2 + 0x - 4 would not be accepted.
Testing
Your program should output the following. Run your program and test your program using your own cases as well.
> first root: foo
> Give me an integer please!
> first root: 2
> second root: -2
> x^2-4
> first root: 1.2
> Give me an integer please!
> first root: 1
> second root: 2
> x^2-3x+2
> first root: 0
> second root: -5
> x^2+5x
> first root: -4
> second root: 5
> x^2-x-20
> first root: 0
> second root: 0
> x^2
> first root: 1
> second root: 0
> x^2-x
> first root: 5
> second root: 5
> x^2-10x+25
> first root: 287
> second root: -91
> x^2-196x-26117
> first root: 12
> second root: 0.1
> Give me an integer please!
> second root: 0.5
> Give me an integer please!
> second root: 3
> x^2-15x+36
> first root: -3
> second root: -1
> x^2+4x+3
Submission
You should save your program as "lastname_morequadratic.py"
Hints:
Maybe define a separate function that constantly prompts the user until they input an integer! lstrip might be useful to deal with negatives to check if the user inputs an integer.
Be careful with formatting negative coefficients and edge cases.