Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

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 as follows:

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

Although this is a useful learning aid, the user plays a rather passive role, in that all they do is view the definition. The extended problem described below goes further. In this new version they are asked to say whether the definition they are shown is the right one, and then told whether or not the answer they have given is correct.

Box 1 Specification of extended problem

The user can ask to see a random flashcard

They are then shown a glossary entry, together with a definition that is not necessarily correct, and asked to say if the definition is correct or not. They are then told whether their response was right or wrong.

The user can repeatedly choose to either see a random entry, as described above, or choose an option to quit the program

A sample dialogue might run as follows:

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

-Here is a glossary entry:

-word3

-Here is a possible definition for it:

-definition1

-Is the definition correct? Enter Y or N: Y

-Your answer was wrong

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

-Here is a glossary entry:

-word2

-Here is a possible definition for it:

-definition2

-Is the definition correct? Enter Y or N: Y

-Your answer was right

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

-Here is a glossary entry:

-word3

-Here is a possible definition for it:

-definition1 Is the definition correct? Enter Y or N: N

-Your answer was right

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

-Here is a glossary entry:

-word1

-Here is a possible definition for it:

-definition1

-Is the definition correct? Enter Y or N: N

-Your answer was wrong

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

For the purposes of developing the program we have used a small glossary with just three dummy entries, chosen so we can easily see which definitions are the right ones. In the sample dialogue above notice that

First the definition displayed was incorrect, and the user entered Y, so they were wrong.

Next the definition displayed was correct, and the user entered Y, so they were right.

Next the definition displayed was incorrect, and the user entered N, so they were right.

Finally, the definition displayed was correct, and the user entered N, so they were wrong.

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)(vi). 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 learnt Anything you learned from the task that would be useful if you faced a similar problem in the future.
  • a.

    • i.First write an algorithm for the following subproblem, taken from Box 1

      They [the user] are then shown a glossary entry, together with a definition that is not necessarily correct, and asked to say if the definition is correct or not. They are then told whether their response was right or wrong.

      The steps of your algorithm must be written in English, not Python code.

      Below we have written the start of the algorithm. You should copy this and then add the remaining steps.

      >> Show flashcard

      Choose a random glossary key

      Choose another random glossary key

      Decide randomly whether to display the correct or incorrect definition

      Display the random glossary key

      Display either the correct or incorrect definition, as appropriate

    • ii.Implementing the part of the algorithm that you added will involve using one of the patterns taught. State the name of the pattern and the pattern number.
    • iii.To apply your chosen pattern you now need to instantiate it, that is replace the general values used in the pattern by the specific ones needed for the solution of the current problem. You should assume that the user will always enter either Y or N, so you will not require an interactive loop. Include your instantiation of the pattern in your Solution Document.
    • iv.Discuss briefly how you will test the program, bearing in mind that the entries will be chosen at random, as will whether the correct or incorrect answer is displayed, and you have no control over this. So, you need to think what you need to do in order to convince yourself the program is working correctly. Only a brief answer is required, and you do not need to give examples, only describe what approach you will follow.
    • v.Now you will implement the instantiated pattern as Python code

      The starter script is a modified version of the first complete version of the flashcard program as developed. In the definition of show_flashcard() we have provided additional code that implements the first steps of the algorithm, as given in Part i. above

      Choose a random glossary key

      Choose another random glossary key

      Decide randomly whether to display the correct or incorrect definition

      Display the random glossary key

      Display either the correct or incorrect definition, as appropriate

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

      Also make sure you write a suitable docstring for the modified function.

You should aim to use only the Python features that are introduced in the module.

You should not make any changes to any other part of the program; all the code you add must be where indicated.

If you were unable to get the function working correctly, you should still explain briefly how the results are different from what you were expecting.

  • Suggest one further small extension or improvement of your own to the modified flashcard program. Outline what the extension does and briefly outline what additional algorithmic steps would be needed. Note that you are only required to describe the extension, as specified above, and do not need to implement it in code

Please give an algorithm as well. Thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions