Find the answer to your Linux question:
Results 1 to 3 of 3
I'm just barely starting to learn programming, and Python in particular. Anyways, I am trying to run this program, but get an error that I'll post at the end. Any ...
  1. #1
    Linux Newbie danbuter's Avatar
    Join Date
    May 2007
    Posts
    108

    Python - error message

    I'm just barely starting to learn programming, and Python in particular. Anyways, I am trying to run this program, but get an error that I'll post at the end. Any suggestions?

    # quadratic.py
    # A program that computes the real roots of a quadratic equation.
    # Illustrates the use of the math library.
    # Note: This program crashes if the equation has no real roots.

    import math # Makes the math library available

    def main():
    print "This program finds the real solutions to a quadratic equation"
    print

    a, b, c = input("Please enter the coefficients (a, b, c): "

    discRoot = math.sqrt(b * b - 4 * a * c)
    root1 = (-b + discRoot) / (2 * a)
    root2 = (-b - discRoot) / (2 * a)

    print
    print "The solutions are:", root1, root2

    main()


    The error is as follows:

    Invalid syntax at line 14. (the discRoot = math.sqrt line).
    Dan

  2. #2
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    your
    Code:
    a, b, c = input("Please enter the coefficients (a, b, c): "
    is missing a final closing brace.

  3. #3
    Linux Newbie danbuter's Avatar
    Join Date
    May 2007
    Posts
    108
    Doh! Thanks!!!!
    Dan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...