Re: Working with decimals part 2

2014-08-27 Thread Seymore4Head
On Tue, 26 Aug 2014 10:46:56 +1000, alex23 wrote: >On 26/08/2014 3:55 AM, Seymore4Head wrote: >> I changed the program just a little to give myself a little practice >> with number formats. The main thing I wanted to do was make the >> decimal points line up. The problem I am having is with the

Re: Working with decimals part 2

2014-08-25 Thread alex23
On 26/08/2014 3:55 AM, Seymore4Head wrote: I changed the program just a little to give myself a little practice with number formats. The main thing I wanted to do was make the decimal points line up. The problem I am having is with the print (count)(payment)(balance) line. While I don't want

Re: Working with decimals part 2

2014-08-25 Thread MRAB
On 2014-08-25 18:55, Seymore4Head wrote: import sys import math def row1(number): return str(number).rjust(3) def row2(number): return str(format(number) ',.2f')) That line has to many ')'. The result of 'format' is a string, so there's no need to use 'str'. def row3(number):

Re: Working with decimals part 2

2014-08-25 Thread Mark Lawrence
On 25/08/2014 18:55, Seymore4Head wrote: import sys import math def row1(number): return str(number).rjust(3) def row2(number): return str(format(number) ',.2f')) def row3(number): return '${:.2f}'.format(number) def row4(number): return '$' + str(format(math.floor(number * 10

Re: Working with decimals part 2

2014-08-25 Thread Chris Angelico
On Tue, Aug 26, 2014 at 3:55 AM, Seymore4Head wrote: > For some reason, it is not working. If I try to use row2 I get this > error: > http://i.imgur.com/FgeF9c9.jpg Several meta-issues. Firstly, your subject line talks about 'decimal' again. You're actually working with floats; Python has a qui

Working with decimals part 2

2014-08-25 Thread Seymore4Head
import sys import math def row1(number): return str(number).rjust(3) def row2(number): return str(format(number) ',.2f')) def row3(number): return '${:.2f}'.format(number) def row4(number): return '$' + str(format(math.floor(number * 100) / 100, ',.2f')) count = 0 payment = 0 borro