Re: [Tutor] Is this correct?

2009-02-09 Thread cclpianos
Hello again, just getting back to the computer, real world etc. I hate to say this, but I never did well in algebra. But I am determined to slog through this to understand it well. On Feb 8, 2009, at 7:29 PM, bob gailer wrote: Please always reply-all so a copy goes to the list. We all parti

Re: [Tutor] Is this correct?

2009-02-09 Thread cclpianos
Hi Bob, I missed this in my in box. Sorry. See below where I have answered your question with yet another. On Feb 8, 2009, at 11:10 AM, bob gailer wrote: cclpia...@comcast.net wrote: HI, I just realized that I shouldn't enclose my project in an attachment. This is my first attempt to string t

Re: [Tutor] Is this correct?

2009-02-08 Thread bob gailer
Please always reply-all so a copy goes to the list. We all participate and learn. Would you also respond to my requests for clarified algorithm? cclpia...@comcast.net wrote: Hi Bob, Thanks for your input! I ran the program in IDLE and it worked just fine. Apparently my calculations were corr

Re: [Tutor] Is this correct?

2009-02-08 Thread bob gailer
For what its worth - here is my revision of your program. I did not send it earlier because I kept finding things that led me to want to see and verify the fundamental algorithm. But now I think my observations could also be useful. My changes: Changed indentation from 8 to 2. For me this is

Re: [Tutor] Is this correct?

2009-02-08 Thread bob gailer
cclpia...@comcast.net wrote: HI, I just realized that I shouldn't enclose my project in an attachment. This is my first attempt to string together py-code. Is this correct? And how would a pro word this? It seems like an awful lot of code for such a small task. I think we should start with

[Tutor] Is this correct?

2009-02-08 Thread cclpianos
HI, I just realized that I shouldn't enclose my project in an attachment. This is my first attempt to string together py-code. Is this correct? And how would a pro word this? It seems like an awful lot of code for such a small task. Thanks in advance, Pat

Re: [Tutor] Is this correct syntax for what I want?

2006-06-25 Thread Alan Gauld
> File "C:\Python24\Account Tracker.py", line 10, in load_file >amount = line.next().strip() > AttributeError: 'str' object has no attribute 'next' > > According to it, the 'str' object has no attribute 'next'. So how > would I load my file containing my data? The str object in question is l

Re: [Tutor] Is this correct syntax for what I want?

2006-06-25 Thread Nathan Pinno
Message - From: "Alan Gauld" <[EMAIL PROTECTED]> To: "Nathan Pinno" <[EMAIL PROTECTED]>; Sent: Sunday, June 25, 2006 1:07 AM Subject: Re: [Tutor] Is this correct syntax for what I want? >> File "C:\Python24\Account Tracker.py", line 49, in pri

Re: [Tutor] Is this correct syntax for what I want?

2006-06-25 Thread Nathan Pinno
Thanks, it works now perfectly! Thanks for all the help! - Original Message - From: "Alan Gauld" <[EMAIL PROTECTED]> To: "Nathan Pinno" <[EMAIL PROTECTED]>; Sent: Sunday, June 25, 2006 1:07 AM Subject: Re: [Tutor] Is this correct syntax for what I want?

Re: [Tutor] Is this correct syntax for what I want?

2006-06-25 Thread Alan Gauld
> File "C:\Python24\Account Tracker.py", line 49, in printall >print account,"\t $",accountlist[account]+"\n" > TypeError: unsupported operand type(s) for +: 'float' and 'str' > > So how do I fix this error? What it's saying is you can't add a float and string. If you look at the code you a

Re: [Tutor] Is this correct syntax for what I want?

2006-06-24 Thread Nathan Pinno
: "Nathan Pinno" <[EMAIL PROTECTED]>; Sent: Saturday, June 24, 2006 3:54 PM Subject: Re: [Tutor] Is this correct syntax for what I want? > >> The data structure is: >> mydata = [(Checking, 12.50),(Savings, 34.50)] And I want the result to >> look like this: &

Re: [Tutor] Is this correct syntax for what I want?

2006-06-24 Thread Alan Gauld
> The data structure is: > mydata = [(Checking, 12.50),(Savings, 34.50)] > > And I want the result to look like this: > mydata = [(Checking, 19.50),(Savings, 34.50)] > > So how do I do this? OK, The problem is that you cannot change the contents of a tuple, you can only create a new tuple. The

Re: [Tutor] Is this correct syntax for what I want?

2006-06-23 Thread Alan Gauld
> The data is account name and 12.50 (example). > I want to access the data to add and subtract from it. > For example > 12.50 - 2.25 = 10.25 > 10.25 + 4.75 = 15.00 Sorry, I meant the data structures. You mentioned you had a list of tuples? And you wanted to perform addition./subtraction on memb

Re: [Tutor] Is this correct syntax for what I want?

2006-06-23 Thread Nathan Pinno
<[EMAIL PROTECTED]>; Sent: Friday, June 23, 2006 2:48 PM Subject: Re: [Tutor] Is this correct syntax for what I want? > Nathan, > > Can you show us an example of the data? > And what you want to do to it, ie before and after values. > > Its not clear to me whether you want to

Re: [Tutor] Is this correct syntax for what I want?

2006-06-23 Thread Alan Gauld
the data to use in an addition/subrtraction storing the result elsewhere (which is perfectly possible) Alan G. - Original Message - From: "Nathan Pinno" <[EMAIL PROTECTED]> To: Sent: Friday, June 23, 2006 2:20 AM Subject: [Tutor] Is this correct syntax for what I want? I

Re: [Tutor] Is this correct syntax for what I want?

2006-06-23 Thread murtog_
You can do: letterlist[x] += amount letterlist[x] -= amount Cheers, -- murtog_ [ http://murtog.blogspot.com ] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Is this correct syntax for what I want?

2006-06-22 Thread Terry Carroll
On Thu, 22 Jun 2006, Nathan Pinno wrote: > I want to be able to add and subtract from a number in a tuple in a > list. Is this the correct syntax? > > letterlist[x] = letterlist[x] + amount # for addition > > letterlist[x] = letterlist[x] - amount # for subtraction Try it.

[Tutor] Is this correct syntax for what I want?

2006-06-22 Thread Nathan Pinno
I want to be able to add and subtract from a number in a tuple in a list. Is this the correct syntax?   letterlist[x] = letterlist[x] + amount # for addition   letterlist[x] = letterlist[x] - amount # for subtraction   If this is not correct, what is the correct syntax?   Thanks, Nathan Pinn

Re: [Tutor] Is this correct?

2006-04-16 Thread Kent Johnson
Hoffmann wrote: > So, I wrote the script below: > > class Time: > pass > > hour = int( raw_input('Enter the hour: ') ) > min = int( raw_input('Enter the minute: ') ) > sec = int( raw_input('Enter the sec: ') ) > > time = Time() > time.hours = hour > time.minutes = min > time.seconds

Re: [Tutor] Is this correct?

2006-04-16 Thread Kent Johnson
Hoffmann wrote: > class Time: > def __init__(self, hours = 0, minutes = 0, seconds = > 0): > self.hours = hours > self.minutes = minutes > self.seconds = seconds > > def printTime(self): # By convention, the first > parameter of a metho

Re: [Tutor] Is this correct?

2006-04-16 Thread Alan Gauld
>> Personally I prefer to put the initialisation >> into an __init__() method, > Thanks for your comments. Please, see below a new > version of that exercise. What do you think? > hour = int( raw_input('Enter the hour: ') ) > min = int( raw_input('Enter the minute: ') ) > sec = int( raw_input('

Re: [Tutor] Is this correct?

2006-04-15 Thread Hoffmann
--- Alan Gauld <[EMAIL PROTECTED]> wrote: > Hi, > > > The goal is to write a function printTime that > takes a > > Time object as an argument and prints it in the > form > > hours:minutes:seconds. > > > > So, I wrote the script below: > > > > class Time: > > pass > > > > hour = int( raw_input(

Re: [Tutor] Is this correct?

2006-04-15 Thread Alan Gauld
Hi, > The goal is to write a function printTime that takes a > Time object as an argument and prints it in the form > hours:minutes:seconds. > > So, I wrote the script below: > > class Time: > pass > > hour = int( raw_input('Enter the hour: ') ) > min = int( raw_input('Enter the minute: ') ) >

[Tutor] Is this correct?

2006-04-15 Thread Hoffmann
Hello: This question is regarding the first exercise of the book "How to think Like a Computer Scientist: Learning with Python", by Downey, Elkner, and Meyers, Chapter 13, page 137. The goal is to write a function printTime that takes a Time object as an argument and prints it in the form hours:m