Re: [Tutor] Help - want to display a number with two decimal places

2011-03-05 Thread Steven D'Aprano
Modulok wrote: Notice that 'd' in your string substitution means integers, not floats. Any decimal places will be truncated when using 'd'. For floats use 'f' instead. You an also specify a precision, such as '%.2f' shows two decimal places. However, to make all of your numbers line up nicely,

Re: [Tutor] Help - want to display a number with two decimal places

2011-03-05 Thread Alan Gauld
"Modulok" wrote However, to make all of your numbers line up nicely, regardless of how long they are, you need to look into advanced string formatting via the builtin string method 'format()'. It takes a little practice Or, if your version of Python doesn't support string.format() (pre 2.6

Re: [Tutor] Help - want to display a number with two decimal places

2011-03-04 Thread Modulok
On 3/4/11, lea-par...@bigpond.com wrote: > Hello > > I have created the following code but would like the program to include two > decimal places in the amounts displayed to the user. How can I add this? > > My code: > > > # Ask user to enter purchase price > purchasePrice = input ('Enter purchase

[Tutor] Help - want to display a number with two decimal places

2011-03-04 Thread lea-parker
HelloI have created the following code but would like the program to include two decimal places in the amounts displayed to the user. How can I add this?My code:# Ask user to enter purchase pricepurchasePrice = input ('Enter purchase amount and then press the enter key $') # Tax ratesstateTaxRate =