a little help with my program?

David Lees debl at nonospammytheworld.com
Mon Apr 2 21:08:50 EDT 2001


You do not have the quadratic formula right.  It is
(-b +/- sqrt(b^2-4*a*c))/(2*a)

Note there can be 1 or 2 roots depending on the whether the discriminant
is zero (qty under sqrt).  you need to check for this unless you know
something about the solution ahead of time.

Also note that this is not a computer representation.  You forgot the
multiplication signs in your eqn.

Do a bit of reading on intros to Python, such as:

http://www.hetland.org/python/instant-hacking.php
http://www.honors.montana.edu/~jjc/easytut/easytut/
http://www.crosswinds.net/~agauld/

and more that have links off www.python.org

Have fun.  

David Lees


johnston112 wrote:
> 
> I am trying to make a program that does performs the quadratic function.
> Here is the code:
> 
> import math
> 
> a = input ("Input a ")
> b = input ("Input b ")
> c = input ("Input c ")
> 
> x.real = -(b) + pow(b**2 - 4(a)(c)) / 2
> print x
> 
> I hope I have the actual formula right :P
> But thats not the point :) It dosn't go, could someone tell me how to fix
> it, or just a hint even, which would be better, to make me tihnk for myself
> (I am only new to python).
> Here is what it shows when i run it:
> 
> Traceback (innermost last):
>     File "d:\hacking\source\python\qf.py", line 7, in ?
>         x.real = -(b) + pow(b**2 - 4(a)(c)) / 2
> TypeError: call of non-function (type int)
> 
> So thats what I get. I have x.real because that is a floating point number
> (?) and it said something about a int type, so thats why I tried it.
> 
> Anyway, any help will be appreciated.
> 
> johnston112



More information about the Python-list mailing list