[Chicago] newbie says HI; needs help

J.Almendariz jalmendz at hotmail.com
Fri Jan 20 03:08:55 CET 2006

Dear Python programmers,

I'm introducing myself to you all...and hoping that someone can answer my question at the end of this message.  I'm new to Python (approx. 2 weeks) but have been studying it with great enthusiasm.  I realize that you all are far...far above me--so please have patience.  

I've been studying Python via the Net (at Books 24x7).  My local library doesn't have any books in their brick and mortar site so they subscribe to this service.  But I've purchased "Learning Python, 2nd Ed. and the Python Cookbook 2nd Ed. which will reach me soon. 

I've been principally converting some Pascal scripts into Python.  I have a fun book from the 80's called Elementary Pascal.  The major characters are Sherlock Holmes and Dr. Watson.  In this book...they use Charles Babbage's Analytical Machine to solve mysteries.  I'm a mystery buff and can't resist learning from this book.  But, obviously, I have two big hurdles to overcome--my lack knowledge of Python syntax and the difference between Python and Pascal.

So far, I've managed to solve the 1st murder mystery (while loops) and  the disappearance of Baroness Whitelsey (math operations).  Today I worked out the 3rd problem (input & output):  identifying different cigars from their specific characteristics (Holmes actually wrote a monograph about cigar ash).  Although I figured out how to write the program...I ran into a glitch--that I could not explain logically.

Hope someone can help me out here.  I can't leave mysteries unsolved (just like Holmes).

The purpose of the cigar program is to teach--how to input data...and to out put the correct answer based upon this data.  There are 10 different cigars each with their own characteristics (texture, color, particles in ash, nicotine amount). 

After initializing all the constants and variables, and inputing the raw data -- the cigars must be separated into 2 basic categories.  Once they are separated into either Stock 1 and Stock 2 they can be further categorized (using IF and ELSE).

Problem:  originally I wrote:

if texture == "flaky" or "caked":
    stock = 1
    stock = 2  

This never worked.  Cigars with "varied, fluffy, granular, " textures always ended up as stock 1.  So did the "flaky and caked".  

When I changed the line to:

if texture != "flaky" or "caked":
    stock = 2
    stock = 1
the program works great.   I have no idea why.  Can anyone help me.

Judy Almendariz
jla314 at yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/chicago/attachments/20060119/d7e62953/attachment.html 

More information about the Chicago mailing list