Page 277 -
P. 277
page goal header
You were to take your pencil and mark the parts of the code on
the previous (and facing) page to identify the code you would
extract and turn into functions so that you can then connect the
functions to the buttons in your GUI. You were also to mark the
other parts of this program that also need to be added to the GUI
version:
You were to think about how many functions you might need. You
were to write their names here:
play_correct_sound()
You need a function to play_wrong_sound() ...and another function
play a sound when the to play a sound when the
answer is correct... answer is wrong.
The GUI program still
import pygame.mixer
needs to use pygame.
def wait_finish(channel):
while channel.get_busy():
pass
sounds = pygame.mixer
sounds.init()
correct_s = sounds.Sound("correct.wav")
wrong_s = sounds.Sound("wrong.wav")
prompt = "Press 1 for Correct, 2 for Wrong, or 0 to Quit: "
number_asked = 0
You still need to maintain
number_correct = 0
number_wrong = 0 these counters.
242 Chapter 7