Question 16 is about a darts game played against a computer.
The aim of the game is to get as close to a target score of 50 as possible, without going over 50. If your score goes over 50, you lose.
The player's score starts at 0.
For each turn:
At the end of the game, the program should run as follows:
Write a Python program to simulate this game.
The first line of the program must import the random library:
import random
The dart throws must be generated using random.randint(a, b) which returns a random integer in the range a to b inclusive.
You should use meaningful variable names and correct Python syntax in your answer.
Dart 1: 12
Dart 2: 8
Current score: 20
Throw again? yes
Dart 1: 15
Dart 2: 10
Current score: 45
Throw again? yes
Dart 1: 5
Dart 2: 4
Current score: 54
Bust! You lose.
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.