Skip to content
MathsGenie logo
Open app

Course home

  1. GCSE
  2. Computer Science AQA
  3. Question bank

Programming concepts

EasyMediumHard
1234567891011121314151617181920212223
Question 10

Write a Python program to simulate an adventure game called 'Treasure Hunt'.

The rules of the game are as follows:

  • The player starts with a gold count of 0.
  • In each turn, two 10-sided dice are rolled (generating random numbers between 1 and 10).
  • The program displays the value of each roll.
  • If the two dice show identical values (a double), the player's gold is immediately reset to 0, the program prints a trap message, and the game ends.
  • If the two dice have different values, their sum is multiplied by 10 and added to the player's current gold count, and the updated gold count is displayed.
  • The program then asks the player if they want to explore further ('y' or 'n').
  • If the player enters 'n', the program displays their final gold count and stops.
  • If the player enters 'y', the program repeats the rolling phase.

You can see an example of two different executions below:

Example Run 1 (Double rolled):

Roll 1: 3
Roll 2: 7
Current gold: 100
Would you like to explore further? (y/n): y

Roll 1: 5
Roll 2: 5
Trap sprung! You lose all your gold!

Example Run 2 (Player stops):

Roll 1: 2
Roll 2: 8
Current gold: 100
Would you like to explore further? (y/n): y

Roll 1: 4
Roll 2: 1
Current gold: 150
Would you like to explore further? (y/n): n
Game over! Your final gold count is: 150

You should use meaningful variable names, correct data types, and proper syntax in your answer.

[11]

Programming concepts Questions

  1. GCSE
  2. /Computer Science
  3. /Programming concepts