(Very Newbie) Problems defining a variable

2008-12-12 Thread febaen
#!/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 = 0.006

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread feba
On Dec 12, 5:56 am, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid 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))

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Steven D'Aprano
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 = : rate =

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Chris Rebert
On Fri, Dec 12, 2008 at 3:42 AM, feb...@gmail.com wrote: #!/usr/bin/python #Py3k, UTF-8 snip #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 =

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread bearophileHUGS
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 = 4:            

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Bruno Desthuilliers
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 = :

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Bruno Desthuilliers
feba a écrit : On Dec 12, 5:56 am, Bruno Desthuilliers bruno. 42.desthuilli...@websiteburo.invalid 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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread feba
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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Marc 'BlackJack' Rintsch
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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Benjamin Kaplan
On Fri, Dec 12, 2008 at 12:50 PM, Dennis Lee Bieber wlfr...@ix.netcom.comwrote: 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 =

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Tim Rowe
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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread MRAB
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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Kirk Strauser
At 2008-12-12T18:12:39Z, Tim Rowe digi...@gmail.com 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,

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread John Machin
On Dec 13, 4:50 am, Dennis Lee Bieber wlfr...@ix.netcom.com 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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Tim Rowe
2008/12/12 Kirk Strauser k...@daycos.com: def get_rate(balance): for threshold, rate in ((10, .0173), (5, .0149), (25000, .0124), (1, .0085), (0, .006)): if

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread John Machin
On Dec 13, 5:18 am, Kirk Strauser k...@daycos.com wrote: At 2008-12-12T18:12:39Z, Tim Rowe digi...@gmail.com 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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Tim Rowe
2008/12/12 John Machin sjmac...@lexicon.net: (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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Kirk Strauser
At 2008-12-12T19:20:52Z, John Machin sjmac...@lexicon.net 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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread John Machin
On Dec 13, 6:49 am, Tim Rowe digi...@gmail.com wrote: 2008/12/12 John Machin sjmac...@lexicon.net: (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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Bruno Desthuilliers
Tim Rowe a écrit : 2008/12/12 Kirk Strauser k...@daycos.com: def get_rate(balance): for threshold, rate in ((10, .0173), (5, .0149), (25000, .0124), (1, .0085), (0,

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Lie Ryan
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

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Lie Ryan
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(How much money

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread bearophileHUGS
Kirk Strauser: def get_rate(balance): for threshold, rate in ((10, .0173), (5, .0149), (25000, .0124), (1, .0085), (0, .006)): if balance threshold:

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Scott David Daniels
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