Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
12345678910111213141516
Question 3

Write a subroutine in Python called analyzeSkySector that will count the number of times the string "Supernova" appears in an astronomical grid scan.

The subroutine should:

  • take a 2D array called skyGrid as a parameter
  • count the number of times "Supernova" appears in the skyGrid array
  • output the string "Critical Mass" if there are exactly three "Supernova" items in the array
  • output the total number of "Supernova" items if there are fewer than three.

You must write your own counting routine utilizing nested loops and not use any built-in count functions or methods (such as .count()) that might be available in Python.

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

[8]
Markscheme

Structured programming and subroutines (procedures and functions) Questions

  1. GCSE
  2. /Computer Science
  3. /Structured programming and subroutines (procedures and functions)

131 exam-style questions on AQA GCSE Computer Science Structured programming and subroutines (procedures and functions). Each one has a worked solution and a mark scheme showing where the marks go.

Question bank