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
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
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):
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
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
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
On Mon, Aug 25, 2014 at 12:51 PM, Steven D'Aprano
wrote:
> Chris Angelico wrote:
>
>> I love this list. We can go off on a ridiculously long tangent, simply
>> because I said that it's only *usually* best to put imports at the top
>> of the file. We all agree that it normally is indeed best to hoi
Chris Angelico wrote:
> I love this list. We can go off on a ridiculously long tangent, simply
> because I said that it's only *usually* best to put imports at the top
> of the file. We all agree that it normally is indeed best to hoist
> them, and here we are, arguing over measurement methods on
On Mon, Aug 25, 2014 at 12:16 PM, Steven D'Aprano
wrote:
> Joshua Landau wrote:
>
>
> python -c "import sys; print('math' in sys.modules)"
>> False
>>
>> An even easier check:
>>
> python -c "import time; a = time.time(); import math; b = time.time();
> print(b-a)"
>> 0.000601291656494
Joshua Landau wrote:
python -c "import sys; print('math' in sys.modules)"
> False
>
> An even easier check:
>
python -c "import time; a = time.time(); import math; b = time.time();
print(b-a)"
> 0.0006012916564941406
>
python -c "import math, time; a = time.time(); import m
On Sun, 24 Aug 2014 14:24:19 -0700, Larry Hudson
wrote:
>On 08/24/2014 08:12 AM, Seymore4Head wrote:
>[snip]
>> I almost moved, but I was looking at the print out again for this one:
>> print('%3d $%-13.2f $%-14.2f' % (count, payment, balance))
>>
>> I can't understand why the $%-13.2f is pushed
On 08/24/2014 08:12 AM, Seymore4Head wrote:
[snip]
I almost moved, but I was looking at the print out again for this one:
print('%3d $%-13.2f $%-14.2f' % (count, payment, balance))
I can't understand why the $%-13.2f is pushed against the first
column, but the $%-14.2f is not. It seems like the
On 24 August 2014 20:40, Ian Kelly wrote:
> That's the same check I posted, just using the in operator instead of a
> straight lookup and raising an error.
I think I need to take a break from the internet. This is the second
time in as many threads that I've responded with what I'm commenting
on.
On Sun, Aug 24, 2014 at 1:29 PM, Joshua Landau wrote:
>
> On 24 August 2014 20:25, Joshua Landau wrote:
> > On 24 August 2014 20:19, Ian Kelly wrote:
> >> On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly
wrote:
> >>> On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau
wrote:
> >>> > Is math not already i
On Sun, Aug 24, 2014 at 1:25 PM, Joshua Landau wrote:
> On 24 August 2014 20:19, Ian Kelly wrote:
> > On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly
> wrote:
> >>
> >> On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau
> wrote:
> >> > Is math not already imported by start-up?
> >>
> >> Why would it be
On 24 August 2014 20:25, Joshua Landau wrote:
> On 24 August 2014 20:19, Ian Kelly wrote:
>> On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly wrote:
>>> On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau wrote:
>>> > Is math not already imported by start-up?
>
> I don't mean into the global namespace, bu
On 24 August 2014 20:19, Ian Kelly wrote:
> On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly wrote:
>>
>> On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau wrote:
>> > Is math not already imported by start-up?
>>
>> Why would it be?
>
> It's easy to check, by the way:
>
> $ python -c "import sys; print(s
On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly wrote:
>
> On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau wrote:
> > Is math not already imported by start-up?
>
> Why would it be?
It's easy to check, by the way:
$ python -c "import sys; print(sys.modules['math'])"
Traceback (most recent call last):
On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau wrote:
> Is math not already imported by start-up?
Why would it be?
--
https://mail.python.org/mailman/listinfo/python-list
On 23 August 2014 23:53, Chris Angelico wrote:
> On Sun, Aug 24, 2014 at 8:47 AM, Joshua Landau wrote:
>> On 23 August 2014 23:31, Chris Angelico wrote:
>>> I'd say "never" is too strong (there are times when it's right to put
>>> an import inside a function), but yes, in this case it should rea
On Sun, 24 Aug 2014 00:04:29 -0700, Larry Hudson
wrote:
>On 08/23/2014 02:13 PM, Seymore4Head wrote:
>> On Sat, 23 Aug 2014 13:47:20 -0400, Seymore4Head
>>
>> I found this function that I will be saving for later.
>> def make_it_money(number):
>> import math
>> return '$' + str(format(m
On Sun, 24 Aug 2014 00:04:29 -0700, Larry Hudson
wrote:
>On 08/23/2014 02:13 PM, Seymore4Head wrote:
>> On Sat, 23 Aug 2014 13:47:20 -0400, Seymore4Head
>>
>> I found this function that I will be saving for later.
>> def make_it_money(number):
>> import math
>> return '$' + str(format(m
On 08/23/2014 02:13 PM, Seymore4Head wrote:
On Sat, 23 Aug 2014 13:47:20 -0400, Seymore4Head
I found this function that I will be saving for later.
def make_it_money(number):
import math
return '$' + str(format(math.floor(number * 100) / 100, ',.2f'))
(I still need more practice to fi
On Sun, Aug 24, 2014 at 8:47 AM, Joshua Landau wrote:
> On 23 August 2014 23:31, Chris Angelico wrote:
>> On Sun, Aug 24, 2014 at 7:47 AM, Joshua Landau wrote:
>>> So for one "import math" should never go inside a function; you should
>>> hoist it to the top of the file with all the other import
On 23 August 2014 23:31, Chris Angelico wrote:
> On Sun, Aug 24, 2014 at 7:47 AM, Joshua Landau wrote:
>> So for one "import math" should never go inside a function; you should
>> hoist it to the top of the file with all the other imports.
>
> I'd say "never" is too strong (there are times when i
On Sun, Aug 24, 2014 at 7:47 AM, Joshua Landau wrote:
> So for one "import math" should never go inside a function; you should
> hoist it to the top of the file with all the other imports.
I'd say "never" is too strong (there are times when it's right to put
an import inside a function), but yes,
On Sat, 23 Aug 2014 22:52:09 +0100, Joshua Landau
wrote:
>On 23 August 2014 18:47, Seymore4Head wrote:
>> Anyone care to suggest what method to use to fix the decimal format?
>
>It sounds like you want a primer on floating point. The documentation
>of the decimal module is actually a good read,
On 23 August 2014 22:13, Seymore4Head wrote:
> def make_it_money(number):
> import math
> return '
> + str(format(math.floor(number * 100) / 100, ',.2f'))
So for one "import math" should never go inside a function; you should
hoist it to the top of the file with all the other imports.
Yo
On 23 August 2014 18:47, Seymore4Head wrote:
> Anyone care to suggest what method to use to fix the decimal format?
It sounds like you want a primer on floating point. The documentation
of the decimal module is actually a good read, although I don't doubt
there are even better resources somewhere
On Sat, 23 Aug 2014 13:47:20 -0400, Seymore4Head
wrote:
>I am trying to do this example:
>http://openbookproject.net/pybiblio/practice/wilson/loan.php
>The instructions warn that floating point math can get messy so I
>cheated a little bit to get me going.
>
>I made my program work by using numbe
On 23/08/2014 20:48, Seymore4Head wrote:
Thanks for the links. The python-course looks like a beginner start.
It raises one more question.
Some have suggested using strings. I understand that strings and
numbers are not the same thing. I know that converting numbers to
strings can be useful
On Sat, 23 Aug 2014 20:24:41 +0100, Mark Lawrence
wrote:
>On 23/08/2014 20:07, Seymore4Head wrote:
>>
>> Funny, I though using the web would be better than a book. I don't
>> think so anymore. Using the web, it is hard to find square one
>> tutorial text.
>>
>
>Try typing something like "python
On 23/08/2014 20:07, Seymore4Head wrote:
Funny, I though using the web would be better than a book. I don't
think so anymore. Using the web, it is hard to find square one
tutorial text.
Try typing something like "python string formatting tutorial" into your
favourite search engine and you'
On Sat, Aug 23, 2014 at 3:07 PM, Seymore4Head
wrote:
> On Sat, 23 Aug 2014 14:21:03 -0400, Joel Goldstick
> wrote:
>
>>On Sat, Aug 23, 2014 at 1:47 PM, Seymore4Head
>> wrote:
>>> I am trying to do this example:
>>> http://openbookproject.net/pybiblio/practice/wilson/loan.php
>>> The instructions
On Sat, 23 Aug 2014 14:21:03 -0400, Joel Goldstick
wrote:
>On Sat, Aug 23, 2014 at 1:47 PM, Seymore4Head
> wrote:
>> I am trying to do this example:
>> http://openbookproject.net/pybiblio/practice/wilson/loan.php
>> The instructions warn that floating point math can get messy so I
>> cheated a li
On Sat, Aug 23, 2014 at 1:47 PM, Seymore4Head
wrote:
> I am trying to do this example:
> http://openbookproject.net/pybiblio/practice/wilson/loan.php
> The instructions warn that floating point math can get messy so I
> cheated a little bit to get me going.
>
> I made my program work by using numb
I am trying to do this example:
http://openbookproject.net/pybiblio/practice/wilson/loan.php
The instructions warn that floating point math can get messy so I
cheated a little bit to get me going.
I made my program work by using numbers that wouldn't get messy.
Instead of using 6% interest I used
37 matches
Mail list logo