Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314
Question 3
Hard

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]

Structured programming and subroutines (procedures and functions) Questions

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