<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: My first real Python program</title>
	<atom:link href="http://techyoyo.com/2009/08/first-python-program-newton-square-root/feed/" rel="self" type="application/rss+xml" />
	<link>http://techyoyo.com/2009/08/first-python-program-newton-square-root/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=first-python-program-newton-square-root</link>
	<description>Tech for the Cool</description>
	<lastBuildDate>Sun, 29 Aug 2010 12:54:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Encrypt message using Python &#124; TechYoYo</title>
		<link>http://techyoyo.com/2009/08/first-python-program-newton-square-root/comment-page-1/#comment-62</link>
		<dc:creator>Encrypt message using Python &#124; TechYoYo</dc:creator>
		<pubDate>Fri, 28 Aug 2009 14:17:15 +0000</pubDate>
		<guid isPermaLink="false">http://techyoyo.com/?p=76#comment-62</guid>
		<description>[...] can check out the code for finding out root of a number using Newton&#8217;s method of iteration in Python. This code cipher code is from the free ebook Invent Your Own Computer Games with [...]</description>
		<content:encoded><![CDATA[<p>[...] can check out the code for finding out root of a number using Newton&#8217;s method of iteration in Python. This code cipher code is from the free ebook Invent Your Own Computer Games with [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: arun kamath</title>
		<link>http://techyoyo.com/2009/08/first-python-program-newton-square-root/comment-page-1/#comment-61</link>
		<dc:creator>arun kamath</dc:creator>
		<pubDate>Thu, 27 Aug 2009 12:36:20 +0000</pubDate>
		<guid isPermaLink="false">http://techyoyo.com/?p=76#comment-61</guid>
		<description>Thanks for the solution. More discussions at Reddit http://www.reddit.com/r/Python/comments/9edvq/my_first_real_python_program_however_there_is_a/</description>
		<content:encoded><![CDATA[<p>Thanks for the solution. More discussions at Reddit <a href="http://www.reddit.com/r/Python/comments/9edvq/my_first_real_python_program_however_there_is_a/" rel="nofollow">http://www.reddit.com/r/Python/comments/9edvq/my_first_real_python_program_however_there_is_a/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Ritchford</title>
		<link>http://techyoyo.com/2009/08/first-python-program-newton-square-root/comment-page-1/#comment-60</link>
		<dc:creator>Tom Ritchford</dc:creator>
		<pubDate>Wed, 26 Aug 2009 21:45:46 +0000</pubDate>
		<guid isPermaLink="false">http://techyoyo.com/?p=76#comment-60</guid>
		<description>Hmm, didn&#039;t look to hard at the documentation, did we?

raw_input() returns a string - not a float.

Try:

1. float(raw_input())
2. eval(raw_input())
3. input() (same as 2)

1. is probably the best choice as it&#039;s clearest and you&#039;ll end up with either a float or an error.</description>
		<content:encoded><![CDATA[<p>Hmm, didn&#8217;t look to hard at the documentation, did we?</p>
<p>raw_input() returns a string &#8211; not a float.</p>
<p>Try:</p>
<p>1. float(raw_input())<br />
2. eval(raw_input())<br />
3. input() (same as 2)</p>
<p>1. is probably the best choice as it&#8217;s clearest and you&#8217;ll end up with either a float or an error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Ziegler</title>
		<link>http://techyoyo.com/2009/08/first-python-program-newton-square-root/comment-page-1/#comment-59</link>
		<dc:creator>David Ziegler</dc:creator>
		<pubDate>Wed, 26 Aug 2009 19:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://techyoyo.com/?p=76#comment-59</guid>
		<description>randint won&#039;t take floats. Try:
x = random.randint(1,int(a-1))

Also, I&#039;m not sure if you want to use y==x as your stopping condition. Probably better to use 

if abs(y-x) &lt; e:
  break

where e is some small number. Good luck!</description>
		<content:encoded><![CDATA[<p>randint won&#8217;t take floats. Try:<br />
x = random.randint(1,int(a-1))</p>
<p>Also, I&#8217;m not sure if you want to use y==x as your stopping condition. Probably better to use </p>
<p>if abs(y-x) &lt; e:<br />
  break</p>
<p>where e is some small number. Good luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: photosinensis</title>
		<link>http://techyoyo.com/2009/08/first-python-program-newton-square-root/comment-page-1/#comment-58</link>
		<dc:creator>photosinensis</dc:creator>
		<pubDate>Wed, 26 Aug 2009 19:55:37 +0000</pubDate>
		<guid isPermaLink="false">http://techyoyo.com/?p=76#comment-58</guid>
		<description>If you know a bit about other programming languages (and considering that you&#039;re a CS undergrad, you &lt;i&gt;should&lt;/i&gt;), I recommend Mark Pilgrim&#039;s &lt;a href=&quot;http://www.diveintopython.org/&quot; rel=&quot;nofollow&quot;&gt;Dive Into Python&lt;/a&gt;, which is the authoritative book on the language.   It&#039;s totally free (Mr. Pilgrim himself is a major player in the free and open source software movements), and if you&#039;re on an Ubuntu box, you&#039;ll find it at /usr/share/doc/diveintopython/html/, with the example code at /usr/share/doc/diveintopython/examples (because Python is the backbone of Ubuntu&#039;s not-quite-SDK).  That book covers most of Python&#039;s standard library, including (I believe) Tkinter and sqlite3.

Good luck with your Python endeavors.</description>
		<content:encoded><![CDATA[<p>If you know a bit about other programming languages (and considering that you&#8217;re a CS undergrad, you <i>should</i>), I recommend Mark Pilgrim&#8217;s <a href="http://www.diveintopython.org/" rel="nofollow">Dive Into Python</a>, which is the authoritative book on the language.   It&#8217;s totally free (Mr. Pilgrim himself is a major player in the free and open source software movements), and if you&#8217;re on an Ubuntu box, you&#8217;ll find it at /usr/share/doc/diveintopython/html/, with the example code at /usr/share/doc/diveintopython/examples (because Python is the backbone of Ubuntu&#8217;s not-quite-SDK).  That book covers most of Python&#8217;s standard library, including (I believe) Tkinter and sqlite3.</p>
<p>Good luck with your Python endeavors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manatlan</title>
		<link>http://techyoyo.com/2009/08/first-python-program-newton-square-root/comment-page-1/#comment-57</link>
		<dc:creator>manatlan</dc:creator>
		<pubDate>Wed, 26 Aug 2009 19:53:40 +0000</pubDate>
		<guid isPermaLink="false">http://techyoyo.com/?p=76#comment-57</guid>
		<description>read http://diveintopython.org/</description>
		<content:encoded><![CDATA[<p>read <a href="http://diveintopython.org/" rel="nofollow">http://diveintopython.org/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Goodger</title>
		<link>http://techyoyo.com/2009/08/first-python-program-newton-square-root/comment-page-1/#comment-56</link>
		<dc:creator>David Goodger</dc:creator>
		<pubDate>Wed, 26 Aug 2009 19:49:53 +0000</pubDate>
		<guid isPermaLink="false">http://techyoyo.com/?p=76#comment-56</guid>
		<description>When you run the program and enter a floating point number, you should see a traceback, like this one:

Traceback (most recent call last):
  File &quot;nr.py&quot;, line 4, in 
    x = random.randint(1,a-1)
  File &quot;/usr/lib/python2.5/random.py&quot;, line 215, in randint
    return self.randrange(a, b+1)
  File &quot;/usr/lib/python2.5/random.py&quot;, line 171, in randrange
    raise ValueError, &quot;non-integer stop for randrange()&quot;
ValueError: non-integer stop for randrange()

The last line tells you what the error was, and the indented text above it tells you where it happened. The first section (starting with &quot;File&quot;) tells you where in the topmost file the error happened: your program called random.randint. The second section tells you that random.randint called the randrange function. And the third/last section tells you that randrange has a problem with non-integers and raised an exception.

Look up the documentation for random.randrange and you&#039;ll see that it requires integer bounds, but you&#039;re supplying a floating-point (non-integer) upper bound. To fix this, try replacing:

x = random.randint(1,a-1)

with:

x = random.randint(1, int(a-1))

The code still won&#039;t work with certain input values: try 0, 1, -5, etc. See if you can get your code to work properly (at least, not crash) with such values. Good luck!</description>
		<content:encoded><![CDATA[<p>When you run the program and enter a floating point number, you should see a traceback, like this one:</p>
<p>Traceback (most recent call last):<br />
  File &#8220;nr.py&#8221;, line 4, in<br />
    x = random.randint(1,a-1)<br />
  File &#8220;/usr/lib/python2.5/random.py&#8221;, line 215, in randint<br />
    return self.randrange(a, b+1)<br />
  File &#8220;/usr/lib/python2.5/random.py&#8221;, line 171, in randrange<br />
    raise ValueError, &#8220;non-integer stop for randrange()&#8221;<br />
ValueError: non-integer stop for randrange()</p>
<p>The last line tells you what the error was, and the indented text above it tells you where it happened. The first section (starting with &#8220;File&#8221;) tells you where in the topmost file the error happened: your program called random.randint. The second section tells you that random.randint called the randrange function. And the third/last section tells you that randrange has a problem with non-integers and raised an exception.</p>
<p>Look up the documentation for random.randrange and you&#8217;ll see that it requires integer bounds, but you&#8217;re supplying a floating-point (non-integer) upper bound. To fix this, try replacing:</p>
<p>x = random.randint(1,a-1)</p>
<p>with:</p>
<p>x = random.randint(1, int(a-1))</p>
<p>The code still won&#8217;t work with certain input values: try 0, 1, -5, etc. See if you can get your code to work properly (at least, not crash) with such values. Good luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francois Trahan</title>
		<link>http://techyoyo.com/2009/08/first-python-program-newton-square-root/comment-page-1/#comment-55</link>
		<dc:creator>Francois Trahan</dc:creator>
		<pubDate>Wed, 26 Aug 2009 18:06:50 +0000</pubDate>
		<guid isPermaLink="false">http://techyoyo.com/?p=76#comment-55</guid>
		<description>You should pass only integer arguments to randint and also, you should not use &#039;y == x&#039; as a stop condition since you&#039;re using floating point arithmetics... try something like abs((y-x)/x) &lt; T where T is your &quot;tolerance&quot;, let&#039;s say 1% or 0.00001%... Your teacher will prefer this ;)</description>
		<content:encoded><![CDATA[<p>You should pass only integer arguments to randint and also, you should not use &#8216;y == x&#8217; as a stop condition since you&#8217;re using floating point arithmetics&#8230; try something like abs((y-x)/x) &lt; T where T is your &quot;tolerance&quot;, let&#039;s say 1% or 0.00001%&#8230; Your teacher will prefer this <img src='http://techyoyo.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
