Movatterモバイル変換


[0]ホーム

URL:


a little help with my program?

David Leesdebl 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 discriminantis zero (qty under sqrt).  you need to check for this unless you knowsomething about the solution ahead of time.Also note that this is not a computer representation.  You forgot themultiplication signs in your eqn.Do a bit of reading on intros to Python, such as:http://www.hetland.org/python/instant-hacking.phphttp://www.honors.montana.edu/~jjc/easytut/easytut/http://www.crosswinds.net/~agauld/and more that have links off www.python.orgHave fun.  David Leesjohnston112 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-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp