Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread spir
On 01/25/2014 05:14 AM, Steven D'Aprano wrote: On Fri, Jan 24, 2014 at 10:28:09PM -0500, bob gailer wrote: And please call () parends and [] brackets, and{} braces. Saves a lot of confusion. If you think that parentheses are spelt with a "d", you're certainly confused :-) They're all bracket

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread spir
On 01/24/2014 06:57 PM, Leon S wrote: Here is what I'm trying to do, accept a price of gas, but I want to add the .009 to the price, so that people do not have to type the full amount. Example, 3.49 /gallon would return 3.499 /gallon. This is what I have tried and the results of it. def gas_p

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread spir
On 01/25/2014 09:46 AM, spir wrote: On 01/24/2014 06:57 PM, Leon S wrote: Here is what I'm trying to do, accept a price of gas, but I want to add the .009 to the price, so that people do not have to type the full amount. Example, 3.49 /gallon would return 3.499 /gallon. This is what I have tr

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread Mark Lawrence
On 25/01/2014 03:28, bob gailer wrote: And please call () parends and [] brackets, and{} braces. Saves a lot of confusion. Not in the UK or Australia, with the former being where English came from. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for o

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread bob gailer
On 1/24/2014 10:28 PM, bob gailer wrote: Sorry for misspelling parens. My reason for requesting the various names is that it makes communication clear, explicit and terse. When someone says just "brackets" what does he actually mean? For more grins see http://www.codinghorror.com/blog/2008/

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Oscar Benjamin
On 25 January 2014 08:57, spir wrote: > On 01/25/2014 09:46 AM, spir wrote: >> >> On 01/24/2014 06:57 PM, Leon S wrote: >>> >>> Here is what I'm trying to do, accept a price of gas, but I want to add >>> the >>> .009 to the price, so that people do not have to type the full amount. >>> Example,

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Keith Winston
On Sat, Jan 25, 2014 at 3:57 AM, spir wrote: >> .009 to the price, so that people do not have to type the full amount. >> Example, 3.49 /gallon would return 3.499 /gallon. >> >> This is what I have tried and the results of it. >> >> def gas_price(price): >> price == raw_input("What is the pr

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Keith Winston
On Sat, Jan 25, 2014 at 3:57 AM, spir wrote: > Note: AFAIK most financial software use integers for this reason and to > avoid (or control) rounding errors. I don't think this is true (no flame intended, hopefully you know I'm forever in your debt Denis): there's a famous scam where insiders at a

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Oscar Benjamin
On 25 January 2014 21:01, Keith Winston wrote: > > I think that you should probably do your math in floating point (why > get complicated? And you might need the accuracy, for hundredths of > dollars and interest) and then format the output to be what you want. > Watch out for rounding. It may no

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread Alan Gauld
On 25/01/14 19:39, bob gailer wrote: On 1/24/2014 10:28 PM, bob gailer wrote: Sorry for misspelling parens. My reason for requesting the various names is that it makes communication clear, explicit and terse. When someone says just "brackets" what does he actually mean? In UK English speakin

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Keith Winston
Also, just to be clear: I'd suggest floats because decimal requires importing a module and using the non-built-in features thereof, especially if you're going to do something like decimal.getcontext().prec (even that doesn't set precision AFTER the decimal point... only total precision). My point b

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Alan Gauld
On 25/01/14 21:19, Keith Winston wrote: On Sat, Jan 25, 2014 at 3:57 AM, spir wrote: Note: AFAIK most financial software use integers for this reason and to avoid (or control) rounding errors. I don't think this is true I can't speak for the general case but the only major financial app I'v

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Oscar Benjamin
On 25 January 2014 21:38, Keith Winston wrote: > > Also, just to be clear: I'd suggest floats because decimal requires > importing a module and using the non-built-in features thereof, Importing a module is not something to be afraid of. Python comes with loads of modules especially so you can im

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread spir
On 01/25/2014 10:01 PM, Keith Winston wrote: On Sat, Jan 25, 2014 at 3:57 AM, spir wrote: .009 to the price, so that people do not have to type the full amount. Example, 3.49 /gallon would return 3.499 /gallon. This is what I have tried and the results of it. def gas_price(price): pri

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread spir
On 01/25/2014 10:19 PM, Keith Winston wrote: On Sat, Jan 25, 2014 at 3:57 AM, spir wrote: Note: AFAIK most financial software use integers for this reason and to avoid (or control) rounding errors. I don't think this is true (no flame intended, hopefully you know I'm forever in your debt Deni

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread spir
On 01/25/2014 10:38 PM, Keith Winston wrote: Also, just to be clear: I'd suggest floats because decimal requires importing a module and using the non-built-in features thereof The issue is not that much whether it's supported by builtins, in software, but by CPU's; which is not the case, so th

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread Steven D'Aprano
On Sat, Jan 25, 2014 at 09:11:56AM +0100, spir wrote: > As a foreigner, I noticed that english native speakers use both the series > round / square / curly / angle brackets, and individual terms parens (no > 'd' ;-) / brackets / braces / chevrons. No major issue, except for > 'brackets' which c

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread Steven D'Aprano
On Sat, Jan 25, 2014 at 02:39:11PM -0500, bob gailer wrote: > On 1/24/2014 10:28 PM, bob gailer wrote: > > Sorry for misspelling parens. > > My reason for requesting the various names is that it makes > communication clear, explicit and terse. > > When someone says just "brackets" what does he

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread Mark Lawrence
On 26/01/2014 01:55, Steven D'Aprano wrote: This is an international forum, and English an international language with many slight differences between variations and dialects. Even in American English alone, there are ambiguous terms. "Coke" could mean a beverage by the Coca-Cola company, a gene

Re: [Tutor] How to correct decimal addition.

2014-01-25 Thread Keith Winston
On Sat, Jan 25, 2014 at 5:09 PM, Oscar Benjamin wrote: > Perhaps it would be better though to point at this: round(D('0.123456'), 3) > Decimal('0.123') I think you are right. I didn't even think of round(). I think we have confounded two issues in this thread, the internal representation/acc

Re: [Tutor] code works in windows command but not ubuntu terminal

2014-01-25 Thread spir
On 01/26/2014 02:12 AM, Steven D'Aprano wrote: On Sat, Jan 25, 2014 at 09:11:56AM +0100, spir wrote: As a foreigner, I noticed that english native speakers use both the series round / square / curly / angle brackets, and individual terms parens (no 'd' ;-) / brackets / braces / chevrons. No maj