[Tutor] My First Program

w chun wescpy at gmail.com
Thu Dec 8 08:19:40 CET 2005


looks good for your 1st program.  some improvements that i can think of:

1. notice how you repeat blocks of code?  specifically, i mean: (ask a
question, get the answer, validate the answer).  since this is all
similar code, it's a great place for you to learn what a loop is. 
that way, you only have one copy of that code.

2. in order to pull of #1, you need to learn about Python's data
structures (like shopping bags for data) so that you can save the set
of questions along with their corresponding answers.  then your loop
will just cycle through the Q&A, and you'll only have one place to
debug!  my suggestion would be a tuple of (Q,A) tuple pairs.  and you
will have to play a minor game to get your quiz to start with question
1 rather than 0.

if you want, post your progress as you change your code, and we can
take a look at it.

cheers,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2006,2001
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list