Write a GUI which quizzes the user and provides feedback including sound.
Here are links to the sample code and necessary sound files:
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:
There are other web sites. This is one which is free and convenient.
You may, of course, record your own sounds and use them--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.
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 is "Fluffy", cat is "Spot", and cat 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.
After appending "Silver" to the list cat, cat is now
The list cat now has 4 times, and cat 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 and key are unused, so question and question hold the two questions, and key and key hold the two answers.
You will need to make your own questions and append them to these lists: question and key.