To answer the specific question about square roots below, Python's square root function is in the math module. You can either include this module and invoke it like this:

import math
.
.
.
y = math.sqrt(x)

-or- if you want the sqrt() function brought into your main namespace, you can do it like this:

from math import sqrt
.
.
.
y = sqrt(x)

Either way, y will now have the value of the square root of x.

HTH
HAND


[EMAIL PROTECTED] wrote:
------------------------------

Message: 9
Date: Thu, 24 Jul 2008 18:47:32 -0700 (PDT)
From: Sam Last Name <[EMAIL PROTECTED]>
Subject: [Tutor]  Newbie
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"

mmmkay its me again
Iv'e been learning alot and have found so much joy in making programs that 
solve equations using the input function.
I need Help on this though.
Im trying to make a program where it solves the quadratic formula when you put in the variables. Here wats i got so far. :) and also, is there a function for square root?
a  =  input("What is the variable a?")
b  =  input("What is the variable b?")
c  =  input("What is the variable c?")
# this is where i need help :(
print -b + /sqrt (b*b - 4*a*c)/(2*a) # this of course doesn't work i believe because i don't have the square root function and don know how to make one

Feedback appreciated :)


You're going to need to use your parenthesis differently.  You might have a 
problem with the grouping if you leave it as it is.  It'd be better written as 
this:

print (-b + /sqrt ((b*b) - (4*a*c))/(2*a))

I don't know the function for square root either, but I'm sure one of the 
others will answer that for you.

-Jay

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.python.org/pipermail/tutor/attachments/20080724/b02787c9/attachment.htm>

------------------------------

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


End of Tutor Digest, Vol 53, Issue 87
*************************************

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to