Re: [Tutor] Beginner's question

2012-11-22 Thread Peter O'Doherty
Many, many thanks to all those who replied to my question. I hope the next time I post, it will be with something more advanced. Judging by the volume of replies, is it fair to say that this problem was much too advanced for page 16 of an introductory text? Best wishes, Peter __

Re: [Tutor] Beginner's question

2012-11-22 Thread Steven D'Aprano
On 23/11/12 01:56, Peter O'Doherty wrote: This code appears to work although it's very cumbersome. Is there a better way to do it? Of course it is cumbersome, that's because of the artificial constraints set on the problem. I quote from your description of the problem: "using only the si

Re: [Tutor] Beginner's question

2012-11-22 Thread eryksun
On Thu, Nov 22, 2012 at 7:10 PM, Dave Angel wrote: > > No, the question is what will Python3000 do. Oh, wait, it's already > out, and it's called 3.x Since it's explicitly an error there, it seems > good not to write new code using the misfeature. I meant it along the lines of cross-compatibili

Re: [Tutor] Beginner's question

2012-11-22 Thread Dave Angel
On 11/22/2012 06:57 PM, eryksun wrote: > On Thu, Nov 22, 2012 at 6:49 PM, Steven D'Aprano wrote: >>> will give the same answer each time, for a single run of a script in >>> CPython, but it is unspecified what that answer will be, and may vary by >>> version as well as implementation. >> Correct.

Re: [Tutor] Beginner's question

2012-11-22 Thread eryksun
On Thu, Nov 22, 2012 at 6:49 PM, Steven D'Aprano wrote: > >> will give the same answer each time, for a single run of a script in >> CPython, but it is unspecified what that answer will be, and may vary by >> version as well as implementation. > > Correct. The ordering of None has changed at least

Re: [Tutor] Beginner's question

2012-11-22 Thread eryksun
On Thu, Nov 22, 2012 at 4:43 PM, Dave Angel wrote: > > You're looking at a particular implementation of CPython code, while I'm > looking at Python's docs. In tha language version 2.x, the result is > repeatable, but undefined, deliberately. I wouldn't dispute that. I have no experience with Jyt

Re: [Tutor] Beginner's question

2012-11-22 Thread Steven D'Aprano
On 23/11/12 08:43, Dave Angel wrote: In other words 2> None will give the same answer each time, for a single run of a script in CPython, but it is unspecified what that answer will be, and may vary by version as well as implementation. Correct. The ordering of None has changed at lea

[Tutor] MIT python video [WAS: Re: Hi Don,]

2012-11-22 Thread Don Jennings
On Nov 22, 2012, at 8:11 AM, Waters, Mike [ITSCA Non-J&J] wrote: > Hi Don, first thanks for the support on Python, I find the information very > helpful. You're welcome. You'll find it even more helpful if you send your questions to the whole python tutor list which I've cc'd :>) > I have bee

Re: [Tutor] Beginner's question

2012-11-22 Thread Dave Angel
On 11/22/2012 02:50 PM, eryksun wrote: > On Thu, Nov 22, 2012 at 10:49 AM, Dave Angel wrote: >> >>> >>> >> >> This one first gets into trouble if x is even and y is odd, because if >> tries to compare y with None, which is basically an undefined ordered >> comparison (and illegal in Python3, I

Re: [Tutor] Beginner's question

2012-11-22 Thread eryksun
On Thu, Nov 22, 2012 at 10:49 AM, Dave Angel wrote: > >> x, y, z = 26, 15, 20 >> >> largest = None >> if x %2: >> largest = x >> if y % 2: >> if y > largest: >> largest = y >> if z % 2: >> if z > largest: >> largest = z; >>

Re: [Tutor] Beginner's question

2012-11-22 Thread Oscar Benjamin
On 22 November 2012 12:55, Peter O'Doherty wrote: > Hi list, > Firstly, apologies for the low-level nature of this question - it's really > quite basic but I don't seem to be able to solve it. > > I need to write a program that examines 3 variables x, y, z, and prints the > largest odd number. I'v

Re: [Tutor] Beginner's question

2012-11-22 Thread Dave Angel
On 11/22/2012 10:14 AM, Joel Goldstick wrote: >> > Peter O'Doherty wrote: >>> > > >>> < snip > >>> > > I need to write a program that examines 3 variables x, y, z, and prints >>> > > the largest odd number. I've tried all sorts of variations and this is >>> > > the current version: >>> > > > x

Re: [Tutor] Beginner's question

2012-11-22 Thread Asokan Pichai
How about this? # Assumption x, y, z are all > 0 x, y, z = a = x * (x % 2) b = y * (y % 2) c = z * (z % 2) big = a if big < b: big = b if big < c big = c if big == 0: print "No odd number" else: print big, "is biggest odd number" Asokan Pichai If a language is designed for non-progr

Re: [Tutor] Beginner's question

2012-11-22 Thread Joel Goldstick
On Thu, Nov 22, 2012 at 10:02 AM, Prasad, Ramit wrote: > Peter O'Doherty wrote: > > > > Hi list, > > Firstly, apologies for the low-level nature of this question - it's > > really quite basic but I don't seem to be able to solve it. > > > > I need to write a program that examines 3 variables x, y,

Re: [Tutor] Beginner's question

2012-11-22 Thread Prasad, Ramit
Peter O'Doherty wrote: > > Hi list, > Firstly, apologies for the low-level nature of this question - it's > really quite basic but I don't seem to be able to solve it. > > I need to write a program that examines 3 variables x, y, z, and prints > the largest odd number. I've tried all sorts of vari

Re: [Tutor] Beginner's question

2012-11-22 Thread Peter O'Doherty
On 11/22/2012 03:17 PM, Walter Prins wrote: Hi Peter, On 22 November 2012 12:55, Peter O'Doherty > wrote: Hi list, Firstly, apologies for the low-level nature of this question - it's really quite basic but I don't seem to be able to solve it. I

Re: [Tutor] Beginner's question

2012-11-22 Thread Walter Prins
Hi Peter, On 22 November 2012 12:55, Peter O'Doherty wrote: > Hi list, > Firstly, apologies for the low-level nature of this question - it's really > quite basic but I don't seem to be able to solve it. > > I need to write a program that examines 3 variables x, y, z, and prints > the largest od

Re: [Tutor] Beginner's question

2012-11-22 Thread Peter O'Doherty
Hi Varun, Thanks for your reply. I agree the problem is logic - but how can one inspect one number using if x%2 == 0 and then compare it to two other numbers which should at the same time be checked for "oddness", just using the basic constructs? Thanks, Peter On 11/22/2012 02:06 PM, Varun

[Tutor] Beginner's question

2012-11-22 Thread Peter O'Doherty
Hi list, Firstly, apologies for the low-level nature of this question - it's really quite basic but I don't seem to be able to solve it. I need to write a program that examines 3 variables x, y, z, and prints the largest odd number. I've tried all sorts of variations and this is the current v