feb...@gmail.com wrote:
...
elif bank >= 1 and bank <= 24999:
rate = 0.0085
> ...
Also, (although not useful here as others have pointed out),
note that particular code means the same thing as:
...
elif 1 <= bank <= 24999:
rate = 0.0085
...
--Scott
Kirk Strauser:
> def get_rate(balance):
>for threshold, rate in ((10, .0173),
>(5, .0149),
>(25000, .0124),
>(1, .0085),
>(0, .006)):
>if balance > threshold:
>
On Fri, 12 Dec 2008 09:50:43 -0800, Dennis Lee Bieber wrote:
> On Fri, 12 Dec 2008 03:42:55 -0800 (PST), feb...@gmail.com declaimed the
> following in comp.lang.python:
>
>> #!/usr/bin/python
>> #Py3k, UTF-8
>>
>> bank = int(input("How much money is in your account?\n>>")) target =
>> int(input(
On Fri, 12 Dec 2008 04:58:36 -0800, feba wrote:
> Actually, I have gedit set to four spaces per tab. I have no reason why
> it's showing up that large on copy/paste, but the file itself is fine.
You've set gedit to _show tabs_ as four spaces, but not to substitute
tabs with four spaces.
Go to g
Tim Rowe a écrit :
2008/12/12 Kirk Strauser :
def get_rate(balance):
for threshold, rate in ((10, .0173),
(5, .0149),
(25000, .0124),
(1, .0085),
(0, .006)):
if bala
On Dec 13, 6:49 am, "Tim Rowe" wrote:
> 2008/12/12 John Machin :
>
> > (4) in practice, the "default" action would not be "return 0.0";
> > perhaps something along these lines:
>
> > if balance < -overdraft_limit:
> > raise Exception(...)
>
> That's more likely to be in the withdrawal routine
At 2008-12-12T19:20:52Z, John Machin writes:
> (1) you meant "if balance > threshold:"
balance >= threshold. We both mistyped. :-)
> (2) sequential search can be very fast if the sequence is in
> descending order of probability of occurence ... you might like to
> consider reversing the order
2008/12/12 John Machin :
> (2) sequential search can be very fast if the sequence is in
> descending order of probability of occurence ... you might like to
> consider reversing the order
I find it hard to imagine a bank with so many interest rate thresholds
that the search of the table is likely
On Dec 13, 5:18 am, Kirk Strauser wrote:
> At 2008-12-12T18:12:39Z, "Tim Rowe" writes:
>
>
>
> > Is there a tidy way of making rates and thresholds local to get_rate,
> > without recalculating each time? I suppose going object oriented is
> > the proper way.
>
> > #Py3k,UTF-8
>
> > rates = {0: 0.
2008/12/12 Kirk Strauser :
> def get_rate(balance):
>for threshold, rate in ((10, .0173),
>(5, .0149),
>(25000, .0124),
>(1, .0085),
>(0, .006)):
>if balance > th
On Dec 13, 4:50 am, Dennis Lee Bieber wrote:
> On Fri, 12 Dec 2008 03:42:55 -0800 (PST), feb...@gmail.com declaimed the
> following in comp.lang.python:
>
> > #!/usr/bin/python
> > #Py3k, UTF-8
>
> > bank = int(input("How much money is in your account?\n>>"))
> > target = int(input("How much money
At 2008-12-12T18:12:39Z, "Tim Rowe" writes:
> Is there a tidy way of making rates and thresholds local to get_rate,
> without recalculating each time? I suppose going object oriented is
> the proper way.
>
> #Py3k,UTF-8
>
> rates = {0: 0.006, 1: 0.0085, 25000: 0.0124, 5: 0.0149, 10:
Tim Rowe wrote:
Since we all seem to be having a go, here's my take. By pulling the
rates and thresholds into a dictionary I feel I'm getting a step
closer to the real world, where these would presumably be pulled in
from a database and the number of interest bands might vary. But is
there a tidi
Since we all seem to be having a go, here's my take. By pulling the
rates and thresholds into a dictionary I feel I'm getting a step
closer to the real world, where these would presumably be pulled in
from a database and the number of interest bands might vary. But is
there a tidier way to get 'thr
On Fri, Dec 12, 2008 at 12:50 PM, Dennis Lee Bieber
wrote:
> On Fri, 12 Dec 2008 03:42:55 -0800 (PST), feb...@gmail.com declaimed the
> following in comp.lang.python:
>
> > #!/usr/bin/python
> > #Py3k, UTF-8
> >
> > bank = int(input("How much money is in your account?\n>>"))
> > target = int(input
On Fri, 12 Dec 2008 04:58:36 -0800, feba wrote:
> Actually, I have gedit set to four spaces per tab. I have no reason why
> it's showing up that large on copy/paste, but the file itself is fine.
The file contains one tab character per indentation level and it depends
on the software you use to l
Actually, I have gedit set to four spaces per tab. I have no reason
why it's showing up that large on copy/paste, but the file itself is
fine.
Thanks for the advice Chris, Stephen, I can definitely see how those
are both far better ways of doing it. I have it as:
#!/usr/bin/python
#Py3k, UTF-8
b
feba a écrit :
On Dec 12, 5:56 am, Bruno Desthuilliers wrote:
(snip)
I guess you wanted your first test to be:
if bank <= :
...
(snip)
that's it, thanks! was confused with it being basically in a column of
all >= *.
I replaced it with
if bank <= 0:
p
feba:
> if bank <= 0:
> print("You're in the red!")
> quit()
> elif bank >= 1 and bank <= :
> rate = 0.0060
> elif bank >= 1 and bank <= 24999:
> rate = 0.0085
> elif bank >= 25000 and bank <= 49
On Fri, 12 Dec 2008 04:05:21 -0800, feba wrote:
> that's it, thanks! was confused with it being basically in a column of
> all >= *.
>
> I replaced it with
>
> if bank <= 0:
> print("You're in the red!")
> quit()
> elif bank >= 1 and bank <= :
>
On Fri, Dec 12, 2008 at 3:42 AM, wrote:
> #!/usr/bin/python
> #Py3k, UTF-8
>
>
> #determine the interest rate to use
>if bank >= :
>rate = 0.006
>elif bank >= 1 and bank <= 24999:
>rate = 0.0085
>elif bank >= 25000 and bank <= 4
On Dec 12, 5:56 am, Bruno Desthuilliers wrote:
> feb...@gmail.com a écrit :
>
>
>
> > #!/usr/bin/python
> > #Py3k, UTF-8
>
> > bank = int(input("How much money is in your account?\n>>"))
> > target = int(input("How much money would you like to earn each year?
> > \n>>"))
>
> > interest = 0
> > i =
feb...@gmail.com a écrit :
#!/usr/bin/python
#Py3k, UTF-8
bank = int(input("How much money is in your account?\n>>"))
target = int(input("How much money would you like to earn each year?
\n>>"))
interest = 0
i = 0
while interest < target:
#determine the interest rate to use
if bank >=
#!/usr/bin/python
#Py3k, UTF-8
bank = int(input("How much money is in your account?\n>>"))
target = int(input("How much money would you like to earn each year?
\n>>"))
interest = 0
i = 0
while interest < target:
#determine the interest rate to use
if bank >= :
rate =
24 matches
Mail list logo