On Tue, 26 Aug 2014 10:46:56 +1000, alex23 wuwe...@gmail.com 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
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
On Tue, Aug 26, 2014 at 3:55 AM, Seymore4Head
Seymore4Head@hotmail.invalid 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
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 *
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 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 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
On Sun, 24 Aug 2014 00:04:29 -0700, Larry Hudson org...@yahoo.com
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 '$' +
On Sun, 24 Aug 2014 00:04:29 -0700, Larry Hudson org...@yahoo.com
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 '$' +
On 23 August 2014 23:53, Chris Angelico ros...@gmail.com wrote:
On Sun, Aug 24, 2014 at 8:47 AM, Joshua Landau jos...@landau.ws wrote:
On 23 August 2014 23:31, Chris Angelico ros...@gmail.com wrote:
I'd say never is too strong (there are times when it's right to put
an import inside a
On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau jos...@landau.ws wrote:
Is math not already imported by start-up?
Why would it be?
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau jos...@landau.ws 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'])
On 24 August 2014 20:19, Ian Kelly ian.g.ke...@gmail.com wrote:
On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau jos...@landau.ws wrote:
Is math not already imported by start-up?
Why would it be?
It's easy to check, by
On 24 August 2014 20:25, Joshua Landau jos...@landau.ws wrote:
On 24 August 2014 20:19, Ian Kelly ian.g.ke...@gmail.com wrote:
On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau jos...@landau.ws wrote:
Is math not already
On Sun, Aug 24, 2014 at 1:25 PM, Joshua Landau jos...@landau.ws wrote:
On 24 August 2014 20:19, Ian Kelly ian.g.ke...@gmail.com wrote:
On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly ian.g.ke...@gmail.com
wrote:
On Sun, Aug 24, 2014 at 1:12 PM, Joshua Landau jos...@landau.ws
wrote:
Is math
On Sun, Aug 24, 2014 at 1:29 PM, Joshua Landau jos...@landau.ws wrote:
On 24 August 2014 20:25, Joshua Landau jos...@landau.ws wrote:
On 24 August 2014 20:19, Ian Kelly ian.g.ke...@gmail.com wrote:
On Sun, Aug 24, 2014 at 1:17 PM, Ian Kelly ian.g.ke...@gmail.com
wrote:
On Sun, Aug 24, 2014
On 24 August 2014 20:40, Ian Kelly ian.g.ke...@gmail.com 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
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
On Sun, 24 Aug 2014 14:24:19 -0700, Larry Hudson org...@yahoo.com
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
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 math; b =
time.time();
On Mon, Aug 25, 2014 at 12:16 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info 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)
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:51 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info 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
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
On Sat, Aug 23, 2014 at 1:47 PM, Seymore4Head
Seymore4Head@hotmail.invalid 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
On Sat, 23 Aug 2014 14:21:03 -0400, Joel Goldstick
joel.goldst...@gmail.com wrote:
On Sat, Aug 23, 2014 at 1:47 PM, Seymore4Head
Seymore4Head@hotmail.invalid wrote:
I am trying to do this example:
http://openbookproject.net/pybiblio/practice/wilson/loan.php
The instructions warn that floating
On Sat, Aug 23, 2014 at 3:07 PM, Seymore4Head
Seymore4Head@hotmail.invalid wrote:
On Sat, 23 Aug 2014 14:21:03 -0400, Joel Goldstick
joel.goldst...@gmail.com wrote:
On Sat, Aug 23, 2014 at 1:47 PM, Seymore4Head
Seymore4Head@hotmail.invalid wrote:
I am trying to do this example:
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
On Sat, 23 Aug 2014 20:24:41 +0100, Mark Lawrence
breamore...@yahoo.co.uk 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
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
On Sat, 23 Aug 2014 13:47:20 -0400, Seymore4Head
Seymore4Head@Hotmail.invalid 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
On 23 August 2014 18:47, Seymore4Head Seymore4Head@hotmail.invalid 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
On 23 August 2014 22:13, Seymore4Head Seymore4Head@hotmail.invalid 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
On Sat, 23 Aug 2014 22:52:09 +0100, Joshua Landau jos...@landau.ws
wrote:
On 23 August 2014 18:47, Seymore4Head Seymore4Head@hotmail.invalid 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
On Sun, Aug 24, 2014 at 7:47 AM, Joshua Landau jos...@landau.ws 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
On 23 August 2014 23:31, Chris Angelico ros...@gmail.com wrote:
On Sun, Aug 24, 2014 at 7:47 AM, Joshua Landau jos...@landau.ws 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
On Sun, Aug 24, 2014 at 8:47 AM, Joshua Landau jos...@landau.ws wrote:
On 23 August 2014 23:31, Chris Angelico ros...@gmail.com wrote:
On Sun, Aug 24, 2014 at 7:47 AM, Joshua Landau jos...@landau.ws wrote:
So for one import math should never go inside a function; you should
hoist it to the top
37 matches
Mail list logo