Re: [Tutor] A better way to estimate the value of Pi?

2011-10-17 Thread Sagar Shankar
Hi Steven, > Can I ask you to please post code using plain text rather than HTML > email (also known as "rich text"), as HTML email messes up the > formatting? In this case, I can reverse-engineer the correct formatting, > so no harm done other than a waste of time, but that won't always be so > e

Re: [Tutor] A better way to estimate the value of Pi?

2011-10-17 Thread Steven D'Aprano
bob gailer wrote: It is not crucial here - but you must recognize that your program uses floating point numbers, which almost always are an approximation to the "real" value. For example (assuming decimal numbers): >>> 4/3.0 1. (followed by an unending number of 0's). Actu

Re: [Tutor] A better way to estimate the value of Pi?

2011-10-17 Thread Dave Angel
On 10/17/2011 11:55 AM, Sagar Shankar wrote: The "real" value of 4/3.0 is 1 followed by an unending number of 3's. Each successive fraction's floating point value will be "off" by some relatively small value. Those errors will probably add up. Another limitation of floating point numbers is

Re: [Tutor] A better way to estimate the value of Pi?

2011-10-17 Thread Steven D'Aprano
Sagar Shankar wrote: Hi Bob, I did use floating point numbers by using 4.0/1.0 - 4.0/3.0 etc., though I did not declare it explicitly. Do you think it's better form/practice to explicitly declare it? Python doesn't use type declarations. 4.0 is already explicitly a float, there's no need to d

Re: [Tutor] A better way to estimate the value of Pi?

2011-10-17 Thread Sagar Shankar
Hi Bob, I did use floating point numbers by using 4.0/1.0 - 4.0/3.0 etc., though I did not declare it explicitly. Do you think it's better form/practice to explicitly declare it? Regards, Sagar On Mon, Oct 17, 2011 at 9:10 PM, bob gailer wrote: > On 10/17/2011 6:31 AM, Sagar Shankar wrote: >

Re: [Tutor] A better way to estimate the value of Pi?

2011-10-17 Thread bob gailer
On 10/17/2011 6:31 AM, Sagar Shankar wrote: Hi, this is my first question to this group. I'm a beginner to computer science and programming in Python. Am currently using John Zelle's book - Python Programming: An introduction to computer science to teach myself.

Re: [Tutor] A better way to estimate the value of Pi?

2011-10-17 Thread Steven D'Aprano
Sagar Shankar wrote: Hi, this is my first question to this group. I'm a beginner to computer science and programming in Python. Am currently using John Zelle's book - Python Programming: An introduction to computer science to teach myself. Hi Sagar, and welcome. Can I ask you to please post co

[Tutor] A better way to estimate the value of Pi?

2011-10-17 Thread Sagar Shankar
Hi, this is my first question to this group. I'm a beginner to computer science and programming in Python. Am currently using John Zelle's book - Python Programming: An introduction to computer science to teach myself. In the book, there is an exercise to create a program that approximates the val