python3 quadratic.py 15 19 4  the answer should be  The solutions are -0.27 and -1.00 its only showing -0.27 and -1.0 when ran , it should be -0.27 and -1.00 not -1.0 import sys

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 9PP: (Data processing) Your professor has asked you to write a C++ program that determines grades at the...
icon
Related questions
Topic Video
Question
100%

python3 quadratic.py 15 19 4 

the answer should be 

  1. The solutions are -0.27 and -1.00

its only showing -0.27 and -1.0 when ran , it should be -0.27 and -1.00 not -1.0

import sys


def main():
    if len(sys.argv) == 4:
        a = float(sys.argv[1])
        b = float(sys.argv[2])
        c = float(sys.argv[3])
        d = (b ** 2) - (4 * a * c)

        if d < 0 or a == 0:
            print("There are no roots")
        else:
            root1 = (-b + d ** 0.5) / (2 * a)
            root2 = (-b - d ** 0.5) / (2 * a)
            print("The solutions are", round(root1,2), "and", round(root2,2))
    else:
        print("Please provide 3 numbers as command line arguments")

main()

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr