[Tutor] Help understanding code

Lisa Sullivan xenacat3 at hotmail.com
Mon Oct 20 10:14:29 EDT 2003


I am new to programming and I'm trying to teach myself Python via online 
tutorials.  I am

struggling with functions.  I wonder if someone could help me.
Here is the URL for the program I am trying to understand:
http://www.honors.montana.edu/~jjc/easytut/easytut/node10.html#SECTION001030000000000000000
I have worked through the program and I understand all but one line.  Below 
is an edited version

of my notes while I was working through understanding the program.
Let me know if I should post the program as well.

  if get_questions(questions[index]):
I don't understand this line.
It seems to move through the list stored in (questions) and determine 
whether or not to increase

right by 1.

Right should only be increased if the question was answered right, so:
That must be what the return statements in the check_question function are 
for.
It replaces the words get_questions with the value returned from running 
get_questions.
We set the variable true to equal 1 and the variable false to = 0.
  if get_questions(questions[index]):
now could say
if 1(questions[index]):
or
if 0(questions)[index]:

(questions) refers to the get_questions info sent to the run_test function 
that we are now inside

of.
and [index] refers to an entry in this list.  But which one?
Is index used to get the index variable we set above?
If so, then right will only be increased:
if 0 or 1(questions[current question]
In other words if the current question is answered correctly or incorrectly.
This doesn't make sense to me.
I don't understand how the program is progressing through the questions.
I don't see how it knows to skip the answers.
I know it has something to do with the fact that the questions and answers 
are stored in lists

that are inside of the main list.

I hope I'm not too far off here.
Thanks for your help.
Lisa

_________________________________________________________________
Add MSN 8 Internet Software to your current Internet access and enjoy 
patented spam control and more.  Get two months FREE!     
http://join.msn.com/?page=dept/byoa




More information about the Tutor mailing list