Skip to content
MathsGenie logo
Open app

Course home

  1. GCSE
  2. Computer Science AQA
  3. Question bank

Programming concepts

EasyMediumHard
1234567891011121314151617181920212223
Question 19

Write a Python program to check if a player has achieved a consecutive streak of five target levels within their 80 completed levels.

When writing your program you should assume:

  • there is an array called targets that contains the completed level numbers of the player's 80 levels
  • targets[0] will contain the value of the first level and targets[79] will contain the value of the last level
  • the values in targets are unique and already stored in ascending numerical order
  • there is a Boolean variable called streakAchieved that has an initial value of False.

Your program should set streakAchieved to True if there is a consecutive streak of five levels (a run of 5 consecutive integers, such as 21, 22, 23, 24, 25).

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

[6]

Programming concepts Questions

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