<?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: Find the Mean/Average of a Number List in Python</title>
	<atom:link href="http://code.hammerpig.com/find-meanaverage-number-list-python.html/feed" rel="self" type="application/rss+xml" />
	<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html</link>
	<description>Tips and short tutorials on various programming technologies</description>
	<lastBuildDate>Sun, 05 Feb 2012 17:17:05 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bhanu</title>
		<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html/comment-page-1#comment-1140</link>
		<dc:creator>Bhanu</dc:creator>
		<pubDate>Mon, 23 Jan 2012 21:17:18 +0000</pubDate>
		<guid isPermaLink="false">http://code.hammerpig.com/?p=513#comment-1140</guid>
		<description>This code worked.

Thanks a lot!</description>
		<content:encoded><![CDATA[<p>This code worked.</p>
<p>Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lvc</title>
		<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html/comment-page-1#comment-673</link>
		<dc:creator>lvc</dc:creator>
		<pubDate>Wed, 13 Apr 2011 04:37:16 +0000</pubDate>
		<guid isPermaLink="false">http://code.hammerpig.com/?p=513#comment-673</guid>
		<description>For python 2.2-2.7, you can just do:
from ___future___ import division
And then sum(nums)/len(nums) will work as expected - no need to convert anything to a float. This is the default in 3.0 on.</description>
		<content:encoded><![CDATA[<p>For python 2.2-2.7, you can just do:<br />
from ___future___ import division<br />
And then sum(nums)/len(nums) will work as expected &#8211; no need to convert anything to a float. This is the default in 3.0 on.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html/comment-page-1#comment-656</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sat, 09 Apr 2011 23:04:25 +0000</pubDate>
		<guid isPermaLink="false">http://code.hammerpig.com/?p=513#comment-656</guid>
		<description>Yeah, that&#039;s a valid point. It should be &quot;not a number.&quot; I&#039;ve updated the code based on your suggestion.</description>
		<content:encoded><![CDATA[<p>Yeah, that&#8217;s a valid point. It should be &#8220;not a number.&#8221; I&#8217;ve updated the code based on your suggestion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mean of no values</title>
		<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html/comment-page-1#comment-655</link>
		<dc:creator>Mean of no values</dc:creator>
		<pubDate>Fri, 08 Apr 2011 09:35:29 +0000</pubDate>
		<guid isPermaLink="false">http://code.hammerpig.com/?p=513#comment-655</guid>
		<description>Is there a definition for mean of no values?
It is not obvious to me that the mean of an empty sequence is 0.0, perhaps division by zero (or a specific exception) is reasonable. It might depend on the use of the function.

Since division by 0 triggers an exception in Python, it might be a good idea to not check in many cases, and use that as a precondition. In other languages were division by 0 will yield NAN and INF which can then be used silently, the check is more important.</description>
		<content:encoded><![CDATA[<p>Is there a definition for mean of no values?<br />
It is not obvious to me that the mean of an empty sequence is 0.0, perhaps division by zero (or a specific exception) is reasonable. It might depend on the use of the function.</p>
<p>Since division by 0 triggers an exception in Python, it might be a good idea to not check in many cases, and use that as a precondition. In other languages were division by 0 will yield NAN and INF which can then be used silently, the check is more important.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: check your own code</title>
		<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html/comment-page-1#comment-533</link>
		<dc:creator>check your own code</dc:creator>
		<pubDate>Tue, 30 Nov 2010 10:28:26 +0000</pubDate>
		<guid isPermaLink="false">http://code.hammerpig.com/?p=513#comment-533</guid>
		<description>dae, you should check your own code.

It should be:

return float( sum(nums) ) / len(nums)

What you had will first calculate sum/len as an integer and then convert it to a float. You end up with interger_result.0</description>
		<content:encoded><![CDATA[<p>dae, you should check your own code.</p>
<p>It should be:</p>
<p>return float( sum(nums) ) / len(nums)</p>
<p>What you had will first calculate sum/len as an integer and then convert it to a float. You end up with interger_result.0</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pk</title>
		<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html/comment-page-1#comment-446</link>
		<dc:creator>pk</dc:creator>
		<pubDate>Sat, 15 May 2010 02:35:05 +0000</pubDate>
		<guid isPermaLink="false">http://code.hammerpig.com/?p=513#comment-446</guid>
		<description>oh wow. that&#039;s a shocker</description>
		<content:encoded><![CDATA[<p>oh wow. that&#8217;s a shocker</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: not division by zero yet</title>
		<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html/comment-page-1#comment-443</link>
		<dc:creator>not division by zero yet</dc:creator>
		<pubDate>Thu, 13 May 2010 15:32:25 +0000</pubDate>
		<guid isPermaLink="false">http://code.hammerpig.com/?p=513#comment-443</guid>
		<description>Your function has input argument numberList but refers to it as floatNums (a variable that is defined in another post therefore outside the scope of your function). There will never be a division by zero because the interpreter will not be able to proceed to the division.</description>
		<content:encoded><![CDATA[<p>Your function has input argument numberList but refers to it as floatNums (a variable that is defined in another post therefore outside the scope of your function). There will never be a division by zero because the interpreter will not be able to proceed to the division.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pk</title>
		<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html/comment-page-1#comment-343</link>
		<dc:creator>pk</dc:creator>
		<pubDate>Fri, 05 Feb 2010 16:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://code.hammerpig.com/?p=513#comment-343</guid>
		<description>hah, division by zero. how embarrasing.</description>
		<content:encoded><![CDATA[<p>hah, division by zero. how embarrasing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dae</title>
		<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html/comment-page-1#comment-342</link>
		<dc:creator>dae</dc:creator>
		<pubDate>Fri, 05 Feb 2010 02:23:04 +0000</pubDate>
		<guid isPermaLink="false">http://code.hammerpig.com/?p=513#comment-342</guid>
		<description>pk is right, python has a built in sum() function, although his code example is sloppy.
def mean(nums):
   if len(nums):
      return float( sum(nums) / len(nums))
   else:
      return 0.0</description>
		<content:encoded><![CDATA[<p>pk is right, python has a built in sum() function, although his code example is sloppy.<br />
def mean(nums):<br />
   if len(nums):<br />
      return float( sum(nums) / len(nums))<br />
   else:<br />
      return 0.0</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pk</title>
		<link>http://code.hammerpig.com/find-meanaverage-number-list-python.html/comment-page-1#comment-227</link>
		<dc:creator>pk</dc:creator>
		<pubDate>Fri, 01 May 2009 13:34:22 +0000</pubDate>
		<guid isPermaLink="false">http://code.hammerpig.com/?p=513#comment-227</guid>
		<description>couldnt you just do

def mean(numberList):
    return float(sum(floatNums)) / len(numberList)</description>
		<content:encoded><![CDATA[<p>couldnt you just do</p>
<p>def mean(numberList):<br />
    return float(sum(floatNums)) / len(numberList)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

