Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
Question 29

Write a Python program to simulate a space mining game called 'Asteroid Miner'.

The rules of the game are as follows:

  • The player starts with a cargo weight of 0.
  • In each turn, two asteroid fragments are drilled, each yielding a random integer amount of mineral between 1 and 10 (inclusive).
  • The program displays the yield of each fragment.
  • If the two fragments yield identical values, a fissure rupture occurs: the player's total cargo weight is immediately reset to 0, the program prints a loss/rupture message, and the game ends.
  • If the two fragments have different yields, their sum is added to the player's current total cargo weight, and the updated weight is displayed.
  • The program then asks the player if they want to drill again ('y' or 'n').
  • If the player enters 'n', the program displays their final cargo weight and stops.
  • If the player enters 'y', the program repeats the drilling phase.

You can see an example of two different executions below:

Example Run 1 (Identical yields):

Fragment 1: 3
Fragment 2: 8
Current cargo: 11
Would you like to drill again? (y/n): y

Fragment 1: 5
Fragment 2: 5
Fissure rupture! Cargo lost!

Example Run 2 (Player stops):

Fragment 1: 2
Fragment 2: 9
Current cargo: 11
Would you like to drill again? (y/n): y

Fragment 1: 7
Fragment 2: 1
Current cargo: 19
Would you like to drill again? (y/n): n
Mission complete! Your final cargo is: 19

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