Beginner: Trying to get REAL NUMBERS from %d command

2012-12-30 Thread Alvaro Lacerda
The code I wrote is supposed to ask the user to enter a number; Then tell the user what's going to happen to that number (x / 2 + 5) ; Then give the user an answer; I succeeded getting results from even numbers, but when I try diving an uneven number (i.e. 5) by 2, I get only the whole number

Re: Beginner: Trying to get REAL NUMBERS from %d command

2012-12-30 Thread Joel Goldstick
On Sun, Dec 30, 2012 at 5:37 PM, Alvaro Lacerda alacerda...@gmail.comwrote: The code I wrote is supposed to ask the user to enter a number; Then tell the user what's going to happen to that number (x / 2 + 5) ; Then give the user an answer; Try x / 2.5 + 5 I succeeded getting results from

Re: Beginner: Trying to get REAL NUMBERS from %d command

2012-12-30 Thread Irmen de Jong
On 30-12-2012 23:37, Alvaro Lacerda wrote: I'm trying to get full number result using the %d command Try %f instead. %d is the formatting symbol for integer numbers. See http://docs.python.org/2/library/stdtypes.html#string-formatting-operations Or have a look at what string.format() can do:

Re: Beginner: Trying to get REAL NUMBERS from %d command

2012-12-30 Thread Vlastimil Brom
2012/12/30 Alvaro Lacerda alacerda...@gmail.com: The code I wrote is supposed to ask the user to enter a number; Then tell the user what's going to happen to that number (x / 2 + 5) ; Then give the user an answer; I succeeded getting results from even numbers, but when I try diving an

Re: Beginner: Trying to get REAL NUMBERS from %d command

2012-12-30 Thread Peter Otten
Alvaro Lacerda wrote: The code I wrote is supposed to ask the user to enter a number; Then tell the user what's going to happen to that number (x / 2 + 5) ; Then give the user an answer; I succeeded getting results from even numbers, but when I try diving an uneven number (i.e. 5) by 2, I

Re: Beginner: Trying to get REAL NUMBERS from %d command

2012-12-30 Thread Hans Mulder
Hello, Python does not support REAL numbers. It has float number, which are approximations of real numbers. They behave almost, but not quite, like you might expect. It also has Decimal numbers. They also approximate real numbers, but slightly differently. They might behave more like you'd

Re: Beginner: Trying to get REAL NUMBERS from %d command

2012-12-30 Thread Alvaro Lacerda
%s got the job done!!! Thank you all for the info and links, I appreciate it! -- http://mail.python.org/mailman/listinfo/python-list

Re: From D

2007-07-31 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: code files? What's the regular expression for locating a number with an arbitrary number of digits seperated into an arbitrary number of blocks of an arbitray number of digits with an arbitrary number of whitespace characters between each block?

Re: From D

2007-07-30 Thread [EMAIL PROTECTED]
Gabriel Genellina wrote: En Tue, 24 Jul 2007 11:10:53 -0300, Stargaming [EMAIL PROTECTED] escribió: On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: There are various things I like about the D language that I think Python too may enjoy. Here are few bits (mostly syntactical

Re: From D

2007-07-26 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: Propose: 123 456 789 = 123456789 123.456 789 = 123.456789 +1 -- http://mail.python.org/mailman/listinfo/python-list

Re: From D

2007-07-26 Thread bearophileHUGS
Sorry for the slow feedback. StargamingSounds like a good thing to be but the arbitrary positioning doesnt make any sense. The arbitrary positioning allows you to denote 4-digit groups too in binary/hex literals, like in my example: auto x = 0b0100_0011; Stargamingfits into the current

Re: From D

2007-07-26 Thread Ben Finney
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: The str.split method has no bearing on this discussion, It most certainly does. To make '123 456' into an integer, you split it and then join it. Indeed. Which has nothing to do with the Python syntax for creating a numeric literal in code. --

Re: From D

2007-07-26 Thread Ben Finney
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: So, just as int('123' '456') 123456 is not an error, the proposal is that a = 123 456 SyntaxError: invalid syntax will not be an error either. More directly: Just as these three statements create the same literal value:

RE: From D

2007-07-26 Thread Ryan Ginstrom
100 ten thousands.) Raymond is correct in that Japan traditionally groups in fours (and stills reads it that way regardless, as shown above), but in an ordinary programming context, this almost never comes into play. On the original topic of the thread, I personally like the underscore idea from

Re: From D

2007-07-26 Thread [EMAIL PROTECTED]
On Jul 26, 12:18 am, Ben Finney [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: IDLE 1.2c1 s = '123 456' s.split() ['123', '456'] The str.split method has no bearing on this discussion, It most certainly does. To make '123 456' into an integer, you split it and

Re: From D

2007-07-26 Thread Leo Petr
On Jul 24, 10:10 am, Stargaming [EMAIL PROTECTED] wrote: On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: There are various things I like about the D language that I think Python too may enjoy. Here are few bits (mostly syntactical ones): 1) (we have discussed part of this in the

Re: From D

2007-07-26 Thread Ben Finney
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: On Jul 25, 8:54?pm, Steven D'Aprano [EMAIL PROTECTED] wrote: Any number of whitespace characters? Just spaces or all whitespace characters? What about searching source code files? What's the regular expression for locating a number with an

Re: From D

2007-07-26 Thread Kay Schluehr
On Jul 25, 7:22 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Jul 24, 6:08 pm, Steven D'Aprano [EMAIL PROTECTED] wrote: On Tue, 24 Jul 2007 20:09:00 +0200, Bjoern Schliessmann wrote: Stargaming wrote: On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: While in a syntax

Re: From D

2007-07-26 Thread Tim Williams
On 26/07/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: The str.split method has no bearing on this discussion, It most certainly does. To make '123 456' into an integer, you split it and then join it. z = '123 456' y = z.split() x = ''.join(y) w = int(x) w 123456 but it

Re: From D

2007-07-26 Thread Ben Finney
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: On Jul 25, 9:04?pm, Steven D'Aprano [EMAIL PROTECTED] wrote: Why does it make no sense? Have you never had to scrape a web page or read a CSV file? Again, unrelated to the way the Python compiler syntactically treats the source code. So this

Re: From D

2007-07-26 Thread [EMAIL PROTECTED]
On Jul 26, 1:24 am, Ben Finney [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: On Jul 25, 9:04?pm, Steven D'Aprano [EMAIL PROTECTED] wrote: Why does it make no sense? Have you never had to scrape a web page or read a CSV file? Again, unrelated to the way the Python

Re: From D

2007-07-25 Thread Jakub Stolarski
On Jul 25, 1:08 am, Steven D'Aprano [EMAIL PROTECTED] wrote: Underscores in numerics are UGLY. Why not take a leaf out of implicit string concatenation and allow numeric literals to implicitly concatenate? Python already does: hello- world = hello-world Propose: 123 456 789 = 123456789

Re: From D

2007-07-25 Thread Wildemar Wildenburger
Steven D'Aprano wrote: Python already does: hello- world = hello-world Propose: 123 456 789 = 123456789 123.456 789 = 123.456789 I second that! /W -- http://mail.python.org/mailman/listinfo/python-list

Re: From D

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 24, 6:08 pm, Steven D'Aprano [EMAIL PROTECTED] wrote: On Tue, 24 Jul 2007 20:09:00 +0200, Bjoern Schliessmann wrote: Stargaming wrote: On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: While in a syntax like: for i in xrange(1_000_000): my eyes help me group them at

Re: From D

2007-07-25 Thread star . public
On Jul 25, 1:22 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: So, spaces will no longer be delimiters? Won't that cause much wailing and gnashing of teeth? I can't think of a circumstance in which 48 1906 is valid, so . . . I like it, too :) -- Star Weaver --

Re: From D

2007-07-25 Thread Steven D'Aprano
On Wed, 25 Jul 2007 18:17:19 -0700, [EMAIL PROTECTED] wrote: On Jul 25, 8:00 pm, Ben Finney [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: On Jul 24, 6:08 pm, Steven D'Aprano [EMAIL PROTECTED] wrote: Python already does: hello- world = hello-world Propose:

Re: From D

2007-07-25 Thread Ben Finney
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: On Jul 24, 6:08 pm, Steven D'Aprano [EMAIL PROTECTED] wrote: Python already does: hello- world = hello-world Propose: 123 456 789 = 123456789 123.456 789 = 123.456789 So, spaces will no longer be delimiters? I don't see how you get

Re: From D

2007-07-25 Thread Steven D'Aprano
On Wed, 25 Jul 2007 10:22:46 -0700, [EMAIL PROTECTED] wrote: On Jul 24, 6:08 pm, Steven D'Aprano [EMAIL PROTECTED] wrote: On Tue, 24 Jul 2007 20:09:00 +0200, Bjoern Schliessmann wrote: Stargaming wrote: On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: While in a syntax like:

Re: From D

2007-07-25 Thread Ben Finney
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: IDLE 1.2c1 s = '123 456' s.split() ['123', '456'] The str.split method has no bearing on this discussion, which is about the Python language syntax, and numeric literal values in particular. -- \Pinky, are you pondering what I'm

Re: From D

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 25, 8:00 pm, Ben Finney [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: On Jul 24, 6:08 pm, Steven D'Aprano [EMAIL PROTECTED] wrote: Python already does: hello- world = hello-world Propose: 123 456 789 = 123456789 123.456 789 = 123.456789 So,

Re: From D

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 25, 8:54?pm, Steven D'Aprano [EMAIL PROTECTED] wrote: On Wed, 25 Jul 2007 10:22:46 -0700, [EMAIL PROTECTED] wrote: On Jul 24, 6:08 pm, Steven D'Aprano [EMAIL PROTECTED] wrote: On Tue, 24 Jul 2007 20:09:00 +0200, Bjoern Schliessmann wrote: Stargaming wrote: On Tue, 24 Jul 2007

Re: From D

2007-07-25 Thread Marc 'BlackJack' Rintsch
On Wed, 25 Jul 2007 10:47:33 -0700, Paddy wrote: But then,what would _0 be, the number 0 or the name _0 analagous to a0 Of course the name because numbers have to start with a digit or a dot. Otherwise this would break backwards compatibility. Ciao, Marc 'BlackJack' Rintsch --

Re: From D

2007-07-25 Thread Paddy
On Jul 25, 1:47 am, Gabriel Genellina [EMAIL PROTECTED] wrote: En Tue, 24 Jul 2007 11:10:53 -0300, Stargaming [EMAIL PROTECTED] escribió: On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: There are various things I like about the D language that I think Python too may enjoy. Here

Re: From D

2007-07-25 Thread [EMAIL PROTECTED]
On Jul 25, 9:04?pm, Steven D'Aprano [EMAIL PROTECTED] wrote: On Wed, 25 Jul 2007 18:17:19 -0700, [EMAIL PROTECTED] wrote: On Jul 25, 8:00 pm, Ben Finney [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] writes: On Jul 24, 6:08 pm, Steven D'Aprano [EMAIL PROTECTED] wrote:

From D

2007-07-24 Thread bearophileHUGS
There are various things I like about the D language that I think Python too may enjoy. Here are few bits (mostly syntactical ones): 1) (we have discussed part of this in the past) You can put underscores inside number literals, like 1_000_000, the compiler doesn't enforce the position of such

Re: From D

2007-07-24 Thread Stargaming
On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: There are various things I like about the D language that I think Python too may enjoy. Here are few bits (mostly syntactical ones): 1) (we have discussed part of this in the past) You can put underscores inside number literals, like

Re: From D

2007-07-24 Thread Bjoern Schliessmann
Stargaming wrote: On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: While in a syntax like: for i in xrange(1_000_000): my eyes help me group them at once. Sounds like a good thing to be but the arbitrary positioning doesnt make any sense. Checking underscore positions would

Re: From D

2007-07-24 Thread Steven D'Aprano
On Tue, 24 Jul 2007 20:09:00 +0200, Bjoern Schliessmann wrote: Stargaming wrote: On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: While in a syntax like: for i in xrange(1_000_000): my eyes help me group them at once. Sounds like a good thing to be but the arbitrary

Re: From D

2007-07-24 Thread [EMAIL PROTECTED]
On Jul 24, 5:19 am, [EMAIL PROTECTED] wrote: There are various things I like about the D language that I think Python too may enjoy. Here are few bits (mostly syntactical ones): 1) (we have discussed part of this in the past) You can put underscores inside number literals, like 1_000_000, the

Re: From D

2007-07-24 Thread Gabriel Genellina
En Tue, 24 Jul 2007 11:10:53 -0300, Stargaming [EMAIL PROTECTED] escribió: On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: There are various things I like about the D language that I think Python too may enjoy. Here are few bits (mostly syntactical ones): 1) (we have discussed