Photo AI

A game displays a picture and the user is asked to spell the matching word by entering letters - Scottish Highers Computing Science - Question 8 - 2022

Question icon

Question 8

A-game-displays-a-picture-and-the-user-is-asked-to-spell-the-matching-word-by-entering-letters-Scottish Highers Computing Science-Question 8-2022.png

A game displays a picture and the user is asked to spell the matching word by entering letters. When a correct letter is entered by the user the letter is filled in... show full transcript

Worked Solution & Example Answer:A game displays a picture and the user is asked to spell the matching word by entering letters - Scottish Highers Computing Science - Question 8 - 2022

Step 1

Process 1

96%

114 rated

Answer

The first process of the game involves displaying a picture and prompting the user to guess the word that corresponds to that picture by entering letters.

Step 2

Process 2

99%

104 rated

Answer

The second process involves checking whether the entered letters are correct and filling the corresponding boxes with the correct letters, while also displaying the number of letters the user has correctly guessed.

Step 3

Using a design technique of your choice, design a program to read in this file, pick one of the words at random and assign it to a variable called chosenWord.

96%

101 rated

Answer

To implement this:

  1. Open the file 'threeLetters.txt' for reading.
  2. Store the words in a suitable data structure, such as a list.
  3. Generate a random number within the range of the list length to select a word at random.
  4. Assign the randomly selected word to the variable called chosenWord.

Step 4

i) assign the variable hintOne the first letter of the word stored in the chosenWord.

98%

120 rated

Answer

hintOne = chosenWord[0]

Step 5

ii) assign the variable hintTwo a random letter from the word stored in the chosenWord variable.

97%

117 rated

Answer

// Assuming a language like Python import random randomIndex = random.randint(0, len(chosenWord) - 1) hintTwo = chosenWord[randomIndex]

Step 6

Using a programming language of your choice, write the code to implement this feature.

97%

121 rated

Answer

numLetters = 0 usedLetters = [] letter = input('Enter a letter: ')

while letter in usedLetters: print('Letter already used. Please try again.') letter = input('Enter a letter: ') usedLetters.append(letter) numLetters += 1

Join the Scottish Highers students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;