Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Develop code

EasyMediumHard
123456789101112
Question 3

Liam has started to write a program to help students practice their Spanish vocabulary.

Open Q05 in your IDE.

The program already:

  • reads a list of Spanish words and their English translations from a file into a 2D list called vocab_list (where each element is [spanish_word, english_translation])
  • displays the following menu:
                                Menu
-----
[1] Register student username
[2] Play Spanish vocab challenge
[3] Terminate session
-----
Input your menu choice:
  • asks for the user's menu choice.

Write the program code to implement the functionality for each menu choice.

Menu choice [1] Register student username

If a student chooses this option, they must be prompted to input their username, which is then stored.

Menu choice [2] Play Spanish vocab challenge

If a player chooses this option, then:

  • they must answer exactly five vocabulary questions
  • for each question, they select which vocabulary word to translate by entering a valid index number (1 to the length of the list)
  • each index can only be selected once per game (they must not be allowed to choose a number they have already used)
  • the Spanish word at that index must be displayed
  • they must input their English translation guess
  • if the guess is correct (ignoring case), their score must be incremented by 1
  • if the guess is incorrect, the correct English translation must be displayed.

Menu choice [3] Terminate session

If the user chooses this option, the student's username and their final score should be displayed, and the program should exit.

Your program must function correctly even if the number of vocabulary pairs in the text file increases or decreases.

Save your code as Q05FINISHED with the correct file extension for your programming language.

[20]

Develop code Questions

  1. IGCSE
  2. /Computer Science
  3. /Develop code