Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
Question 38

Write a Python program to simulate a dice game called 'Double Trouble'.

The rules of the game are as follows:

  • The player starts with a score of 0.
  • In each turn, two 6-sided dice are rolled (generating random numbers between 1 and 6).
  • The program displays the value of each roll.
  • If the two dice show identical values (a double), the player's score is immediately reset to 0, the program prints a lose message, and the game ends.
  • If the two dice have different values, their sum is added to the player's current total score, and the updated score is displayed.
  • The program then asks the player if they want to roll again ('y' or 'n').
  • If the player enters 'n', the program displays their final score 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: 5
Current score: 8
Would you like to roll again? (y/n): y

Roll 1: 4
Roll 2: 4
Double rolled! You lose!

Example Run 2 (Player stops):

Roll 1: 2
Roll 2: 6
Current score: 8
Would you like to roll again? (y/n): y

Roll 1: 5
Roll 2: 1
Current score: 14
Would you like to roll again? (y/n): n
Game over! Your final score is: 14

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

[11]
Markscheme

Programming concepts Questions

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

298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank