Re: [Tutor] Trouble with exercise regarding classes

2010-08-28 Thread Andrew Martin
Ok I think I got it. Thanks everybody. And sorry for the late reply. My classes have just started so learned python unfortunately must be bumped down on the priority list On Thu, Aug 26, 2010 at 4:32 AM, Alan Gauld alan.ga...@btinternet.comwrote: Andrew Martin amartin7...@gmail.com wrote I

Re: [Tutor] Trouble with exercise regarding classes

2010-08-26 Thread Alan Gauld
Andrew Martin amartin7...@gmail.com wrote I want to compare zenith, a floating point number, with the current y value? I thought the current y value could be retrieved by Projectile.getY. Projectile.getY is a reference to the getY method of the Projectile class. (See the separate thread

[Tutor] Trouble with exercise regarding classes

2010-08-25 Thread Andrew Martin
I just starting programming and am trying to learn some python (ver 2.6). I am reading Python Programming: An Introduction to Computer Science by John Zelle. In chapter ten, the first programming exercise asks the reader to modify code from the chapter (below) . The code I added is highlighted.

Re: [Tutor] Trouble with exercise regarding classes

2010-08-25 Thread Alan Gauld
Andrew Martin amartin7...@gmail.com wrote However, when I did so I got this error: TypeError: unbound method getY() must be called with Projectile instance as first argument (got nothing instead) def main(): angle, vel, h0, time = getInputs() cball = Projectile(angle, vel, h0)

Re: [Tutor] Trouble with exercise regarding classes

2010-08-25 Thread Andrew Martin
All I want to do is add a line that displays that maximum height the cannonball reaches. I created a variable zenith to store the highest y value. I then wanted to compare the current y value of the cannonball to zenith while the cannonballs y value is greater than zero. If the cannonballs current

Re: [Tutor] Trouble with exercise regarding classes

2010-08-25 Thread Alex Hall
On 8/25/10, Andrew Martin amartin7...@gmail.com wrote: All I want to do is add a line that displays that maximum height the cannonball reaches. I created a variable zenith to store the highest y value. I then wanted to compare the current y value of the cannonball to zenith while the

Re: [Tutor] Trouble with exercise regarding classes

2010-08-25 Thread Nitin Das
There are 2 ways to get the ypos value one is cball.ypos and another is call.getY() both will give u the current ypos. --nitin On Thu, Aug 26, 2010 at 7:26 AM, Andrew Martin amartin7...@gmail.comwrote: All I want to do is add a line that displays that maximum height the cannonball reaches. I

Re: [Tutor] Trouble with exercise regarding classes

2010-08-25 Thread Denis Gomes
Andrew, For starters you have some errors in the way you are trying to access methods from within a class instances. For example in your code in line 7 and 8, def main(): angle, vel, h0, time = getInputs() cball = Projectile(angle, vel, h0) zenith = 0.0 while cball.getY() =