Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
Question 51

A student is writing a climbing simulation game in Python.

Figure 1

0123456
RR

Figure 2

  • The climber starts at position 0 in a list of handholds representing a cliff.
  • The aim of the game is for the climber to reach the very top of the cliff (the final index in the list).
  • At each turn, the climber must enter either 1 or 2 to climb up that many spaces:
    • Entering 1 increases the climber's position by 1.
    • Entering 2 increases the climber's position by 2.
  • If the climber's position goes beyond the end of the list (overshoots) or lands on a loose rock (marked by 'R'):
    • the message Slipped! is displayed
    • the climber's position is reset back to 0
  • These steps are repeated until the climber reaches the final index of the list.

Figure 3

position = 0
top_index = len(cliff) - 1
while position < top_index:

Extend the program from Figure 3 so that the game works as described in Figure 2.

When writing your program you should assume:

  • there is a list called cliff
  • the number of 'R' characters in cliff can vary
  • the position of the 'R' characters in cliff can vary
  • the 'R' characters have already been added to the list called cliff
  • the cliff list can be of any length.

You should use indentation as appropriate, meaningful variable name(s), and Python syntax in your answer.

[8]
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