[Tutor] Newbie

John Fouhy john at fouhy.net
Fri Jul 25 04:17:33 CEST 2008


On 25/07/2008, Sam Last Name <the_sam_smart at yahoo.com> wrote:
>
> Okay thanks still didnt get it working but one step closer. Take a look at
> this
>
>
> a = input("What is the variable a?")
> b = input("What is the variable b?")
> c = input("What is the variable c?")
> print -b + [((b*b - 4*a*c)**0.5)/(2*a)]
> # my new equation thanks to you :)
>
>
> i run the script and here is error message there are 2 messages. i will post
> both.
>
> What is the variable a?2
> What is the variable b?2
> What is the variable c?2
>
> Traceback (most recent call last):
>   File "C:\Python\Script2.py", line 4, in <module>
>     print -b + [((b*b - 4*a*c)**0.5)/(2*a)]
> ValueError: negative number cannot be raised to a fractional power

This is normal; if you want to handle complex numbers you will need to
do a lot more work..

> # i changed the numbers so it would be postive number when squarerooting and
> it worked but then this error popped up :(
>
>
> What is the variable a?2
> What is the variable b?14
> What is the variable c?5
>
> Traceback (most recent call last):
>   File "C:\Python\Script2.py", line 4, in <module>
>     print -b + [((b*b - 4*a*c)**0.5)/(2*a)]
> TypeError: unsupported operand type(s) for +: 'int' and 'list'
>
> # I"m bewildered to what that means. ty for feed back :) this is so i can do
> alegbra2 easily haha.

Different types of brackets mean different things in python.  You
can't just use square brackets instead of round brackets to make it
easier to read :-)  In this case, square brackets indicates a list and
python is complaining that it doesn't know how to add an integer (-b)
to a list ([..]).  I recommend reading through the tutorial on
python.org.

PS.  Please use the reply-all when using this mailing list so other
people can follow the conversation if they wish to.

-- 
John.


More information about the Tutor mailing list