Please send questions to st10@humboldt.edu .

*   some random projected notes from Week 8 Lecture, 3-5-07

*   IMPORTANT ANNOUNCEMENTS:
    *   There will be NO LAB on WEDNESDAY, MARCH 7th

    *   CIS 130 HW #5 will be accepted as ON-TIME if it is submitted
        by the beginning of class on Wednesday, March 21

    *   CIS 130 HW #6 will not be due until after Exam #2 (but it will
        be available well before then, if you'd like to work ahead)

    *   Note that Spring Break does not count as a semester week -
        so, Week 9's lecture is on Monday, March 19, and so the Exam #2
        to be held in Week 10 will be on Monday, March 26th.

*   sentinel-controlled loop: yet-another common pattern!

*   in this style, you repeat until the user enters a special
    non-data value, that means "it's time to stop!"

*   how might I do this? example:

    say I want to ask for the attendance at some number
    of performances, and then print the total;

# Contract: total_attendance: void -> void
# Purpose: to ask user to enter number attending
#          each of an un-predetermined number of
#          performances, until they enter a -1 to
#          stop; then print to the screen the
#          total attendance at all those performances
# Example: if when total_attendance() is called, the
#          user types (when prompted) 10, 30, 20, -1,
#          the program should print to the screen:
# The total attendance is: 60

def total_attendance():

    # initializing needed variables

    total_so_far = 0

    # get first attendance

    print "Please enter first attendance value, "
    current_attendance = int(raw_input("...or any negative number " +
                                       "to quit: "))

    # adding up the total attendance at all performances 

    while (current_attendance >= 0):

        total_so_far = total_so_far + current_attendance

        # NOTE that the following would ALSO make total_so_far
        # bigger by current_attendance:
        #  total_so_far += current_attendance 
 
        # get next attendance

        print "Please enter next attendance value, "
        current_attendance = int(raw_input("...or any negative number " +
                                       "to quit: "))

    # now print the total attendance

    print "The total attendance is: " + str(total_so_far)

*   DEBUGGING TIP: can't figure out why your code isn't doing what
    you think it should?

    *   insert TEMPORARY print statements, to help DEBUG!

    *   put a print at the beginning of a loop, to print the
        value of a loop-control variable or to just show
        how many times you enter the loop (or if you do!)

    *   put a print in EACH branch of an if/elif/elif.../else,
        to see exactly which is actually reached;

    *   put a print at the beginning of a function, to see
        if it is ever called (and with what arguments it was called);

    *   ...get it?

    *   (and once you've found the problem - REMOVE the debugging
        print statements! 8-) )