The program should allow the user to ask for a glossary flashcard

You must give a word count for any question part with a maximum word limit.

This question tests your understanding of Block 3 Part 2 (found in the same folder as this file) , and, more generally, the problem-solving and Python programming skills that are covered by the module. The question is concerned with an extension to the flashcard problem you studied in Block 3 Part 2.

You will find it useful to read through the whole question before starting to answer it.

In the original flashcard problem, a user can ask the program to show an entry picked randomly from a glossary. When the user presses return, the program shows the definition corresponding to that entry. The user is then given the option of seeing another entry or quitting.

A sample session might run like this:

Enter s to show a flashcard and q to quit: s

Define: word1

Press return to see the definition

definition1

Enter s to show a flashcard and q to quit: s

Define: word3

Press return to see the definition

definition3

Enter s to show a flashcard and q to quit: q

In the modified version the user is sometimes shown the entry first and then the definition, but sometimes they are shown in reverse order. Which order is followed – entry then definition or definition then entry – is decided randomly.

Box 1 – Statement of extended problem

The program should allow the user to ask for a glossary flashcard. In response, the program should pick an entry at random from all glossary entries. It should then choose at random whether to show the user the entry itself or the associated definition. When the user presses return the user should be shown either the corresponding definition, if the entry was displayed first, or the corresponding entry, if the definition was displayed first.

The user should be able to repeatedly ask for a flashcard and also have the option to quit the program instead of seeing another card.

A sample dialogue might run as follows.

Enter s to show a flashcard and q to quit: s

What is the entry for the definition definition2

Press return to see the entry

word2

Enter s to show a flashcard and q to quit: s

What is the definition for the entry word1

Press return to see the definition

definition1

Enter s to show a flashcard and q to quit: s

What is the entry for the definition definition2

Press return to see the entry

word2

Enter s to show a flashcard and q to quit: q

>>>

For the purposes of developing the program we will use a small glossary with just three dummy entries, chosen so we can easily see which definitions correspond to each entry.

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.

 

 

 

 

 

 

PART A.

a1. The only parts of the code that you will need to change are in the body of the function show_flashcard.

Write an algorithm for the following section in Box 1, reproduced here for convenience.

In response, the program should pick an entry at random from all glossary entries. It should then choose at random whether to show the user the entry itself or the associated definition. When the user presses return the user should be shown either the corresponding definition, if the entry was displayed first, or the corresponding entry, if the definition was displayed first.

The steps of your algorithm must be written in English, not Python code, as algorithms should be implementable in any programming language, not just Python. What pattern from Block 1 Part 1 does your algorithm use? You may find it useful to look through the list of patterns in the Problem solving and Python quick reference (find in ZIP folder)

a2. 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.

a3. Now you will implement your algorithm as Python code.

We have provided a starter script which is included in the download for this TMA as Q2.py. Begin by saving a copy of the provided program as Q2_OUCU.py

The starter script is the first complete version of the flashcard program as developed in Block 3 Part 2. The code that sets up the glossary, and the interactive loop, do not need to be changed and you should not alter these parts of the program in any way.

Complete the new version of show_flashcard() by adding code, where indicated by comments, that will implement the algorithm you produced in Part i. You should use appropriate comments to make it clear how the code you have written corresponds to the steps in the algorithm.

You will need to write code that simulates the toss of a coin, to decide randomly whether to show the entry first or the corresponding definition. This is touched on in subsection 2.2.2 of Block 3 Part 2, which you may find it useful to revisit.

Important: also make sure you write suitable docstrings for the modified function and the program as a whole, to reflect the changed behaviour.

Copy the complete program into your Solution Document. Also include your completed .py file in your TMA zip file.

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!