Talk:Python Programming/Decision Control
>>>a = 6
Gives
>>>print a == 6
true
not 1
in python.
--
RG-12-Mar-2007-14:44
Just a thought: I know that the python code has been included in some of the beginning scripts for this tutorial. I think it would be cool to include the code for all scripts used, like the exercise on this page.
Agreed, at the least a solution should be provided for excersises, in case someone is unable to get the answer. Salgat 23:08, 8 July 2007 (UTC)
I find it pretty strange that most of the examples on this page involve if statements and loops, even though you don't learn them until after this page. Should this book be restructured a little? Alexforcefive (talk) 03:09, 26 March 2008 (UTC)
In the table for the NOT operator the operator (not) is missing in the left column, i.e. the expression to be evaluated: e.g. it should say"not True -> False", "not False -> True". Mariostorti (talk) 13:34, 8 January 2009 (UTC)
I believe the "jack and jill" example is very confusingly coded:
- Uses key-word (list) and built-in name (copy) for variables.
- Deletes 1st item but none others
- Uses "count" where "index" is intended
- Uses different pattern before and during the loop
I'm an experienced programmer who came here to learn Python, but i couldn't tell what the code was trying to do, until I re-wrote it! I propose something like this (comments omited for brevity):
L = ["Life","The Universe","Everything","Jack","Jill","Life","Jill"]
C = L[:]
C.sort()
n = len(C)
i = 0
prev = C[i]
i = i + 1
while i < n and C[i] != prev:
prev = C[i]
i = i + 1
if i < n:
print("First Match:",prev)
martin f --174.6.64.79 (discuss) 18:41, 23 April 2011 (UTC)
Then again, Alexforcefive, was correct. Why have examples that detract from the simple concept of "decision"? martin f
I agree with Alex. I can understand using advanced examples sometimes to get the point across that an eloquent answer exists. But until then could we have a baby version too? What I mean is could we have a solution that involves only the material covered up to this point? Or an explanation of the new material used. My biggest problem, like he said, is that the 'while' keyword isn't covered until the 'loops' section yet it is used in both presented solutions to the exercise.