Re: [Tutor] Count for loops

2017-04-11 Thread eryk sun
On Wed, Apr 12, 2017 at 4:03 AM, boB Stepp wrote: > > I have not used the decimal module (until tonight). I just now played > around with it some, but cannot get it to do an exact conversion of > the number under discussion to a string using str(). Pass a string to the

Re: [Tutor] Count for loops

2017-04-11 Thread eryk sun
On Wed, Apr 12, 2017 at 3:40 AM, boB Stepp wrote: > > I have to say I am surprised by this as well as the OP. I knew that > str() in general makes a nice printable representation The single-argument str() constructor calls the object's __str__ method (or __repr__ if

Re: [Tutor] Count for loops

2017-04-11 Thread boB Stepp
On Tue, Apr 11, 2017 at 3:43 PM, Alan Gauld via Tutor wrote: > On 11/04/17 19:44, Mats Wichmann wrote: > >> import decimal >> >> Pi_Number = >> str(decimal.Decimal(3.14159265358979323846264338327950288419716939)) >> > > Unfortunately that doesn't work either: > " " +

Re: [Tutor] Count for loops

2017-04-11 Thread boB Stepp
On Tue, Apr 11, 2017 at 2:18 PM, Marc Tompkins wrote: > On Tue, Apr 11, 2017 at 9:48 AM, Rafael Knuth > wrote: > >> I tested this approach, and I noticed one weird thing: >> >> Pi_Number = str(3.14159265358979323846264338327950288419716939) >>

Re: [Tutor] Count for loops

2017-04-11 Thread Alan Gauld via Tutor
On 11/04/17 19:44, Mats Wichmann wrote: > import decimal > > Pi_Number = > str(decimal.Decimal(3.14159265358979323846264338327950288419716939)) > Unfortunately that doesn't work either: >>> " " + str(decimal.Decimal( ... 3.14159265358979323846264338327950288419716939)) '

[Tutor] Precision of floating-point number representation (was: Count for loops)

2017-04-11 Thread Ben Finney
Rafael Knuth writes: > I tested this approach, and I noticed one weird thing: > > Pi_Number = str(3.14159265358979323846264338327950288419716939) > Pi_Number = "3" + Pi_Number[2:] > print(Pi_Number) The mistake is in assuming such a precise number would survive

Re: [Tutor] Count for loops

2017-04-11 Thread Mats Wichmann
On 04/11/2017 10:48 AM, Rafael Knuth wrote: > Thanks for the clarification. > I tested this approach, and I noticed one weird thing: > > Pi_Number = str(3.14159265358979323846264338327950288419716939) > Pi_Number = "3" + Pi_Number[2:] > print(Pi_Number) > > == RESTART:

Re: [Tutor] Count for loops

2017-04-11 Thread Alan Gauld via Tutor
On 11/04/17 17:48, Rafael Knuth wrote: > Pi_Number = str(3.14159265358979323846264338327950288419716939) > Pi_Number = "3" + Pi_Number[2:] > print(Pi_Number) > 3141592653589793 > > How come that not the entire string is being printed, but only the > first 16 digits? There are two problems

Re: [Tutor] Count for loops

2017-04-11 Thread Marc Tompkins
On Tue, Apr 11, 2017 at 9:48 AM, Rafael Knuth wrote: > I tested this approach, and I noticed one weird thing: > > Pi_Number = str(3.14159265358979323846264338327950288419716939) > Pi_Number = "3" + Pi_Number[2:] > print(Pi_Number) > > == RESTART:

Re: [Tutor] Question to Phyton and XBee

2017-04-11 Thread Marc Tompkins
On Tue, Apr 11, 2017 at 9:12 AM, Daniel Berger wrote: >Hello, > >I have installed the modules to control xbee with Python >https://pypi.python.org/pypi/XBee). Afterwards I have set the path >variable on C:\Python27\python-xbee-master and also the subdirectories. >

Re: [Tutor] Count for loops

2017-04-11 Thread Rafael Knuth
>>> b = "3"+b[2:] #Removing the decimal point so that there are digits only in >> >> my_number = 3.14159 > > Here you assign a floating point number to mmy_number but > the code Sama wrote was for working with strings read > from a text file. > > You would need to convert it first: > > my_number

[Tutor] Question to Phyton and XBee

2017-04-11 Thread Daniel Berger
Hello, I have installed the modules to control xbee with Python https://pypi.python.org/pypi/XBee). Afterwards I have set the path variable on C:\Python27\python-xbee-master and also the subdirectories. To check, if the modules are available, I have written the code as

Re: [Tutor] [PYTHON27] How to save into .npy file?

2017-04-11 Thread Mats Wichmann
On 04/10/2017 07:17 PM, Steven D'Aprano wrote: > On Mon, Apr 10, 2017 at 02:10:34PM +, Allan Tanaka via Tutor wrote: >> Hi. >> Is there a way to save module type data into .npy file that can be used >> latter? > > What's "module type data"? > > What's a .npy file? > > To answer your