The program should allow the user to ask for a word list entry. In response, the program
Question:
The program should allow the user to ask for a word list entry. In response, the program should randomly pick an entry from the word list. It should display the English word and invite the user to enter the French equivalent. After the user enters their answer, the program should check the answer. If it is correct the program should tell the user; otherwise, if the answer is wrong the program should tell the user and inform them of the correct answer.
The user should be able to repeatedly ask for an entry and also have the option to quit the program instead of seeing another entry.
A sample session might run like this:
Enter s to show a flashcard and q to quit: s
What is the French for red: rouge
Correct, well done!
Enter s to show a flashcard and q to quit: s
What is the French for yellow: vert
Sorry, the answer is jaune
Enter s to show a flashcard and q to quit: s
What is the French for white: blanc
Correct, well done!
Enter s to show a flashcard and q to quit: s
What is the French for yellow: jaune
Correct, well done!
Enter s to show a flashcard and q to quit: q
>>>
For the purposes of developing the program, we will use a small word list with just six entries: the name of a color in English, and its French equivalent.
Box 2 - keeping a notebook:
As you work through part a. of this question you should keep a notebook. You will need this for your answer to part a. iv. This should be very brief: it is simply a record of your personal experience while working on the task and what you feel you have learned from it.
In your notebook we suggest that you record the following information:
How | A brief description of how you went about the task. |
Resources | What documentation, if any, you consulted (including course materials and any online sources) and which you found most useful. There is no need for full references, just note the source, and - in the case of the course materials - what the relevant part and section or activity was. |
Difficulties | Anything you found difficult about the task, and how you dealt with it. |
Lessons learned | Anything you learned from the task that would be useful if you faced a similar problem in the future. |
a.
We have provided a Python file Word_List_Flashcards.py that you should work from when answering this question. If you read this program and run it you will find it is exactly the same as Flashcards_First_Complete_Version.py, except that we have replaced the glossary dictionary and all references to it with a dictionary word_list, which is an English-French word list, and added a comment in the show_flashcard() function.
i.Write an algorithm for the following section in Box 1, reproduced here for convenience.
The program should allow the user to ask for a word list entry. In response, the program should randomly pick an entry from the word list. It should display the English word and invite the user to enter the French equivalent. After the user enters their answer, the program should check the answer. If it is correct the program should tell the user, otherwise, if the answer is wrong the program should tell the user and inform them of the correct answer.
Your algorithm should provide a similar level of detail to the show flashcard algorithm in Subsection 2.5.2 of Block 3 Part 2. Your algorithm should resemble the one shown there, except that the user will need to do more than just press return, and the program will have to evaluate the user response and act accordingly.
ii. Discuss briefly how you will test the program. Only a short answer is required, and you do not need to give examples, only describe what approach you will follow.
iii. Now you will implement your algorithm as Python code, modifying the provided Python program Word_List_Flashcards.py.
- Complete the new version of show_flashcard() by modifying the code so it implements the algorithm you produced in part i.
- Also modify the docstring for the show_flashcard() function and the docstring for the program as a whole, to take account of the changed functionality and behavior.
- The changes you make to the function show_flashcard() should be consistent with the algorithm you gave in part i.
- You should use only the Python features that are introduced in the module. If you consider there is a compelling reason why you need features not taught in TM112 you must explain your reasons, otherwise marks may be lost.
- If you are unable to get the program working correctly, you should still copy your code into your Solution document, with a brief explanation of how the results are different from what you intended.
iv.
Also copy the notebook you kept as you went along into your Solution document and include the final version of your completed Word_List_Flashcards.py file in your TMA submission folder.
b.
Suggest one further small extension or improvement of your own to the modified flashcard program. Outline what the extension or improvement does and briefly describe any additional sub-problem(s) that would need to be added to the initial decomposition.
Note that you are only required to describe your further extension or improvement, you do not need to implement it in code.
The maximum word count for part b. is 150 words, including any added sub-problem(s).
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis