Outcomes and Assessment Standards
Explain how programs work, drawing on an understand of advanced concepts in software development and computer architecture by:
| Assessment Standard | Focus |
|---|---|
| 1.1 | Reading and explaining code |
| 1.2 | Describing the purpose of a range of programming constructs and how they work |
| 1.3 | Describing how a range of standard algorithms work |
| 1.4 | Describing how programs relate to low-level structures and operations |
The range of programming constructs should include subprograms, parameters, user-defined functions and sequential file operations. The range of standard algorithms should include linear search, finding minimum and maximum and counting occurrences.
Assessment Standards 1.1 and 1.2
In a computer game, a bonus score is awarded to a player who guesses the location of an enemy target area. The enemy target areas, for example H2 and G4, are stored in an array called areas.
Read the following code carefully. It is not a complete program.
def loadTargetAreas(): filename = "C:/game/board.txt" file = function(filename, "r") for i (0, 30): areas[i] = file.readline() file.close() def totalScore(score): index = 0 for index in range(0, 30): print("Enter a guess") userGuess = input() if userGuess == areas[index]: score = score + 5 return score result = totalScore(result)
-
1
Why have subprograms been used in this code?
-
2
Explain how one of these subprograms could be called into action.
-
3
What is the purpose of passing parameters into subprograms?
-
4
State what happens to the value that is stored in the variable
resulton line 20 when the subprogramtotalScoreis called. -
5
What is the purpose of file operations?
-
6
Explain in detail how lines 2–8 work.
Assessment Standard 1.3
In a yacht race, each different make and model of yacht is given a handicap. Before the start of a race, the name and handicap of each boat is entered into the referee’s software. This program then records the time taken for the yacht to complete the race (usually around two hours and recorded in seconds, e.g. 7200) and uses the handicap to calculate a race score. The yacht with the lowest resulting race score is the winner.
# Procedure: enterStartDetails def enter_start_details(number_in_race): index = 1 yacht_name = [] handicap = [] while True: print("Please enter the yacht name") yacht_name_input = input() if yacht_name_input == 'NoMore': break yacht_name.append(yacht_name_input) print("Please enter the boat's handicap") handicap_input = int(input()) handicap.append(handicap_input) index += 1 return yacht_name, handicap # Procedure: calculateRaceScores def calculate_race_scores(number_in_race, race_time, handicap): race_score = [0] * number_in_race winning_time = 0 for index in range(number_in_race): race_score[index] = race_time[index] / (handicap[index] * 1000) winning_time = race_score[0] for index in range(1, number_in_race): if race_score[index] < winning_time: winning_time = race_score[index] print(f"{winning_time:.2f}") return winning_time # Procedure: provost def provost(number_in_race, yacht_name): found = False index = 0 while not found and index < number_in_race: if yacht_name[index] == 'RoJo': found = True index += 1 if found: print("The Lord Provost took part in the race")
-
7
Explain how the “Find Minimum” standard algorithm works (as used in the
calculate_race_scoresprocedure). -
8
Explain how the “Linear Search” standard algorithm works (as used in the
provostprocedure).
Assessment Standard 1.4
-
9
Explain how the computer processes the program using the fetch-execute cycle with reference to processor, memory and buses.