Csci 1020 September 23, 2019 Program Assignment 4

Write a GUI which quizzes the user and provides feedback including sound.

Here are links to the sample code and necessary sound files:

s4.py
applause_y.wav
buzzer_x.wav

Sounds and Portability

Python is fairly portable, but there are certain areas which are machine specific if one uses Python as it comes installed--which we do. Sounds can be done in many ways, and we will use WAV files, files which end in the extension .wav. You will need to uncomment exactly one method of using sounds, depending on whether you have a mac, windows, or linux machine. Do leave the options in your code so that other people (like me) can select the correct method of playing sounds depending on which machine the code is ran on.

You must download the sound .wav files and have them in the same directory/folder of the python program which uses them. Here is a nice website to get free .wav sounds--for educational purposes only:

http://www.wavsource.com/sfx/sfx.htm

There are other web sites. This is one which is free and convenient.

You may, of course, record your own sounds and use them without restriction--if you can record and save .wav files. Making your own sounds from scratch is satisfying and fun if you want something special. If you end up making a product or website using sounds, you should make your own or ensure that your sounds are public domain. Free sounds above for Python programming in class are fine to use for educational purposes.

Lists

We have not formally covered lists yet. These are called "arrays" in most other programming languages. Lists are sequences of things: integers, reals, strings, whatever. Here is a list:

cat = ["Fluffy","Spot","Rover"]

Lists are indexed starting at 0, so cat[0] is "Fluffy", cat[1] is "Spot", and cat[2] is "Rover". Note, there are 3 items in the list cat, and the indices are 0,1, and 2.

You can add items to a list with append.

cat.append("Silver")

After appending "Silver" to the list cat, cat is now

["Fluffy","Spot","Rover","Silver"]

The list cat now has 4 times, and cat[3] is "Silver".

You program 4 code should use two lists. One list is to hold questions, and the other list holds answers 1 for True and 0 for False.

The sample code contains two questions, but the lists in the sample code have 3 items. This is done for convenience. question[0] and key[0] are unused, so question[1] and question[2] hold the two questions, and key[1] and key[2] hold the two answers.

You will need to make your own questions and append them to these lists: question and key.


Content is neither approved nor reviewed by FDLTCC.