[Tutor] help beginner in python.

Alan Gauld alan.gauld at btinternet.com
Sun Feb 24 23:53:23 CET 2008


"Krystle Scott" <madpotential at gmail.com> wrote

>i need to write an algorithm for computing square roots.

We don;t do homework here but we can help with specific
questions and to resolve errors.

> import math
>
> def main ():
>      print " This program computes approximate square roots using 
> Newton's
> method: "
>      print
>
>
>     input = (" Enter whose square root you wish to compute (a) : ")
>     input = (" Enter the number of iterations :" )

OK, this is so far off base that I have to ask whether you
have done any Python programming at all before? Where is
this assignment (which I asume it is?) coming from? It seems
kind of unfair to ask you to do this if you haven't even covered
the basics of Python already!

>     discRoot = math.sqrt

Calling python's square root function won't do anything for
implementing Newtons methiod, except maybe prove the
result when you get there is close...

Can you give us a bit more background to where this
challenge is coming from and your bbackground, otherwise
I'd say you need to go through one of the beginners tutorials.
There are many on the Python web site, pick one that looks
good to you.

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
Temorarily at:
http://uk.geocities.com/alan.gauld@btinternet.com/
Normally:
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list