AQA GCSE · Question 16 · Programming
Question 16 is about a dice game played against a computer. The aim of the game is to get as close to a score of 21 as you can, without going over 21. If your score goes over 21 then you lose. The player's score starts at 0.
For each turn:
At the end of the game, the program should work as follows:
The dice rolls are carried out by the program generating random numbers between 1 and 6. You will need to use the Python function random.randrange(a, b) which generates a random integer in the range a to b starting at a but finishing one before b.
Write a Python program to simulate this game.
31 questions · hints · full answers · grading