Skip to content

Course home

Programming concepts

Programming concepts

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
Question 39

Write a Python program to check if a research drone has received a consecutive sequence of six packet IDs within its 150 logged packets.

When writing your program you should assume:

  • there is an array called packetIDs that contains the IDs of the drone's 150 logged packets
  • packetIDs[0] contains the value of the first packet ID and packetIDs[149] contains the value of the last packet ID
  • the values in packetIDs are unique integers and already stored in ascending numerical order
  • there is a Boolean variable called completeSequence that has an initial value of False.

Your program should set completeSequence to True if there is a consecutive sequence of six packet IDs (a run of 6 consecutive integers, such as 104, 105, 106, 107, 108, 109).

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

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