9618/42 · May/June 2025 · Worked solutions

Step-by-step solutions based on the mark scheme (not a mark-scheme dump).

Question 1

Paper page 2 for Q1
Original paper page 2

Part 1(a) — solution

  1. (Global) Stack as 1D array (of strings) with 20 elements initialised to string "–1"
  2. (Global) TopOfStack initialised to –1

Visual Basic (VB.NET)

Dim Stack(19) As String
 Dim TopOfStack As Integer
 For x = 0 To 19
      Stack(x) = "-1"
 Next
 TopOfStack = -1

Python

Stack = []
 TopOfStack = -1
 #main
 for x in range(20):
      Stack.append("-1")

 University Press & Assessment 2025                         Page 7 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme      May/June 2025

Mark points

  • (Global) Stack as 1D array (of strings) with 20 elements initialised to string "–1"
  • (Global) TopOfStack initialised to –1

Part 1(b) — solution

  1. Push function header (and end where appropriate) taking one (string) parameter
  2. Checking if stack is full and returning integer –1
  3. (Otherwise) Incrementing TopOfStack
  4. Storing parameter in the incremented the stack at TopOfStack and returning integer 1

Visual Basic (VB.NET)

Function Push(ByVal Data)
     If TopOfStack = 19 Then
         Return -1
     Else
         TopOfStack = TopOfStack + 1
         Stack(TopOfStack) = Data
         Return 1
     End If
 End Function

 University Press & Assessment 2025                       Page 8 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Python

def Push(Data):
      global Stack
      global TopOfStack
      if TopOfStack == 19:
          return -1
      else:
          TopOfStack += 1
          Stack[TopOfStack] = Data
          return 1

 University Press & Assessment 2025                       Page 9 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Push function header (and end where appropriate) taking one (string) parameter
  • Checking if stack is full and returning integer –1
  • (Otherwise) Incrementing TopOfStack
  • Storing parameter in the incremented the stack at TopOfStack and returning integer 1

Part 1(c) — solution

  1. Function header (and end where appropriate) and returning a value in all cases
  2. Checking if stack is empty and returning string "–1"
  3. (Otherwise) Decrementing TopOfStack
  4. Returning element in stack at TopOfStack before TopOfStack is decremented

Visual Basic (VB.NET)

Function Pop()
     If TopOfStack = -1 Then
         Pop = "-1"
     Else
         Pop = Stack(TopOfStack)
         TopOfStack = TopOfStack - 1
     End If
 End Function

 University Press & Assessment 2025                       Page 10 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Python

def Pop():
      global Stack
      global TopOfStack
      if TopOfStack == -1:
          return "-1"
      else:
          ReturnValue = Stack[TopOfStack]
          TopOfStack -= 1
          return ReturnValue

 University Press & Assessment 2025                       Page 11 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme           May/June 2025

Mark points

  • Function header (and end where appropriate) and returning a value in all cases
  • Checking if stack is empty and returning string "–1"
  • (Otherwise) Decrementing TopOfStack
  • Returning element in stack at TopOfStack before TopOfStack is decremented

Part 1(d) — solution

  1. Procedure header (and end where appropriate) taking one (string) parameter
  2. Opening the file with the filename parameter and closing the file in an appropriate place
  3. Looping through to end of file and reading in each line
  4. … calling Push() once with each read in value …
  5. … if any return value from Push() is integer –1 outputting "Stack full"
  6. Exception handling for opening and reading from file with appropriate catch and output

Visual Basic (VB.NET)

Sub ReadData(ByVal FileName As String)
     Dim ReturnValue As String
     Try
         Dim FileReader As New System.IO.StreamReader(FileName)
         While Not FileReader.EndOfStream
             ReturnValue = Push(FileReader.ReadLine())
             If ReturnValue = "-1" Then
                 Console.WriteLine("Stack full")
             End If
         End While
         FileReader.Close()
     Catch ex As Exception
         Console.WriteLine("Cannot open file")
     End Try
 End Sub

Python

def ReadData(FileName):
      global Stack
      global TopOfStack
      try:
          File = open(FileName)
          for Line in File:
              ReturnValue = Push(Line.strip())
              if ReturnValue == -1:
                  print("Stack full")
          File.close()
      except:
          print("Cannot open file")

 University Press & Assessment 2025                       Page 13 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme                               May/June 2025

Mark points

  • Procedure header (and end where appropriate) taking one (string) parameter
  • Opening the file with the filename parameter and closing the file in an appropriate place
  • Looping through to end of file and reading in each line
  • … calling Push() once with each read in value …
  • … if any return value from Push() is integer –1 outputting "Stack full"
  • Exception handling for opening and reading from file with appropriate catch and output

Part 1(e) — solution

  1. Calculate() function header (and end where appropriate)
  2. Looping until the stack is empty
  3. Calling Pop() repeatedly within loop and storing/using return value
  4. … working out if return value from Pop() call is an operator or a number / alternating between operator and number
  5. Select to determine if the operator is +, -, /, * or ^ and attempt the matching calculation
  6. … performing correct calculation using operator, number
  7. … updating total from previous loops and returning this final value

Visual Basic (VB.NET)

Function Calculate()
     Dim Total As Integer = Pop()
     Dim ReturnValue As String = ""
     Dim LastOperator As String = ""
     Dim OperatorFlag As Boolean = True
     Dim TheData As Integer = 0
     While (ReturnValue <> "-1")
         ReturnValue = Pop()
         Select Case OperatorFlag
             Case False
                 TheData = ReturnValue
                 Select Case LastOperator
                     Case "+"
                         Total = Total + TheData
                     Case "-"
                         Total = Total - TheData
                     Case "*"
                         Total = Total * TheData
                     Case "/"
                         Total = Total / TheData
                     Case "^"
                         Total = Total ^ TheData
                 End Select
                 OperatorFlag = True
             Case Else
                 LastOperator = ReturnValue

 University Press & Assessment 2025                       Page 15 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

                 OperatorFlag = False
         End Select
     End While
     Return Total
 End Function

Python

def Calculate():
      global Stack
      global TopOfStack
      Total = Pop()
      Total = int(Total)
      Return = 0
      LastOperator = ""
      Operator = True
      while(Return != "-1"):
          Return = Pop()
          if Operator == False:
              Data = int(Return)
              if LastOperator == "+":
                  Total = Total + Data
              elif LastOperator == "-":
                  Total = Total - Data
              elif LastOperator == "*":
                  Total = Total * Data
              elif LastOperator == "/":
                  Total = Total / Data
              elif LastOperator == "^":
                  Total = Total ** Data
              Operator = True
         else:
              LastOperator = Return
              Operator = False
     return Total

 University Press & Assessment 2025                       Page 16 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Calculate() function header (and end where appropriate)
  • Looping until the stack is empty
  • Calling Pop() repeatedly within loop and storing/using return value
  • … working out if return value from Pop() call is an operator or a number / alternating between operator and number
  • Select to determine if the operator is +, -, /, * or ^ and attempt the matching calculation
  • … performing correct calculation using operator, number
  • … updating total from previous loops and returning this final value

Part 1(f)(i) — solution

  1. Taking a filename as input and calling ReadData() with input
  2. Calling Calculate() and outputting the return value

Visual Basic (VB.NET)

Console.WriteLine("Enter the filename")
 Dim FileName As String = Console.ReadLine()
 ReadData(FileName)
 Dim ReturnValue As Single
 ReturnValue = Calculate()
 Console.WriteLine(ReturnValue)

Python

FileName = input("Enter the filename: ")
 ReadData(FileName)
 ReturnValue = Calculate()
 print(ReturnValue)

 University Press & Assessment 2025                       Page 17 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Taking a filename as input and calling ReadData() with input
  • Calling Calculate() and outputting the return value

Part 1(f)(ii) — solution

1 mark for screenshot showing input of StackData.txt and output of 131 2

Mark points

  • Include the ideas shown in the solution above.

Part 1 — solution

mark for screenshot showing input of SecondStack.txt and output of 320 e.g. University Press & Assessment 2025 Page 18 of 45 9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025

Mark points

  • Include the ideas shown in the solution above.

Question 2

Paper page 6 for Q2
Original paper page 6

Part 2(a) — solution

  1. Record/class NewRecord declared
  2. 3 variables within structure (all integer)

Visual Basic (VB.NET)

Structure NewRecord
         Dim Key As Integer
         Dim Item1 As Integer
         Dim Item2 As Integer
     End Structure

 University Press & Assessment 2025                       Page 19 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Python

class Record:
      def __init__(self, pKey, pItem1, pItem2):
          self.__Key = pKey #integer
          self.__Item1 = pItem1 #integer
          self.__Item2 = pItem2 #integer

        def GetKey(self):
            return self.__Key
        def GetItem1(self):
            return self.__Item1
        def GetItem2(self):
            return self.__Item2

 University Press & Assessment 2025                       Page 20 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Record/class NewRecord declared
  • 3 variables within structure (all integer)

Part 2(b)(i) — solution

  1. HashTable (200 records) and Spare (100 records) declared as (global) arrays

Visual Basic (VB.NET)

Dim HashTable(199) As NewRecord
 Dim Spare(99) As NewRecord

Python

HashTable = []
 Spare = []

 University Press & Assessment 2025                       Page 21 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme                            May/June 2025

Mark points

  • HashTable (200 records) and Spare (100 records) declared as (global) arrays

Part 2(b)(ii) — solution

  1. Procedure Initialise() header (and close where appropriate) that initialises all elements in both arrays …
  2. … to an empty record with –1 in each of the 3 fields/elements

Visual Basic (VB.NET)

Sub Initialise()
     Dim EmptyRecord As NewRecord
     EmptyRecord.Key = -1
     EmptyRecord.Item1 = -1
     EmptyRecord.Item2 = -1
     For X = 0 To 199
         HashTable(X) = EmptyRecord
     Next
     For X = 0 To 99
         Spare(X) = EmptyRecord
     Next
 End Sub

 University Press & Assessment 2025                       Page 22 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Python

def Initialise():
      global HashTable
      global Spare
      for X in range(200):
          HashTable.append(Record(-1,-1,-1))
      for X in range(100):
          Spare.append(Record(-1,-1,-1))

 University Press & Assessment 2025                       Page 23 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme                                  May/June 2025

Mark points

  • Procedure Initialise() header (and close where appropriate) that initialises all elements in both arrays …
  • … to an empty record with –1 in each of the 3 fields/elements

Part 2(c) — solution

  1. Function header (and close where appropriate), taking one (integer) parameter and returning the calculated value
  2. Calculation of parameter MOD 200

Visual Basic (VB.NET)

Function CalculateHash(Key)
     Return Key Mod 200
 End Function

Python

def CalculateHash(Key):
      return Key % 200

 University Press & Assessment 2025                       Page 24 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme       May/June 2025

Mark points

  • Function header (and close where appropriate), taking one (integer) parameter and returning the calculated value
  • Calculation of parameter MOD 200

Part 2(d) — solution

  1. Procedure header (and end where appropriate) taking one record as a parameter
  2. Calling CalculateHash() with key from parameter record and storing/using return value
  3. Checking if HashTable at return value from CalculateHash is empty record …
  4. … if it is empty, store parameter in location
  5. … otherwise, locating next free space in Spare …
  6. … and storing in that index only (i.e. not in all other free spaces)

Visual Basic (VB.NET)

Sub InsertIntoHash(TheRecord)
     Dim HashValue As Integer = CalculateHash(TheRecord.Key)
     If HashTable(HashValue).Key = -1 Then
         HashTable(HashValue) = TheRecord
     Else
         For X = 0 To 99
             If Spare(X).Key = -1 Then
                 Spare(X) = TheRecord
                 X = 100
             End If
         Next
     End If
 End Sub

 University Press & Assessment 2025                       Page 26 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Python

def InsertIntoHash(TheRecord):
      global HashTable
      global Spare
      HashValue = CalculateHash(TheRecord.GetKey())

        if HashTable[HashValue].GetKey() == -1:
            HashTable[HashValue] = TheRecord

        else:
            for x in range(0, 100):
                if Spare[x].GetKey() == -1:
                    Spare[x] = TheRecord
                    break

 University Press & Assessment 2025                       Page 27 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme         May/June 2025

Mark points

  • Procedure header (and end where appropriate) taking one record as a parameter
  • Calling CalculateHash() with key from parameter record and storing/using return value
  • Checking if HashTable at return value from CalculateHash is empty record …
  • … if it is empty, store parameter in location
  • … otherwise, locating next free space in Spare …
  • … and storing in that index only (i.e. not in all other free spaces)

Part 2(e) — solution

  1. Procedure header (and end where appropriate), opening and closing file HashData.txt
  2. Reading in all lines of data …
  3. … splitting each line by commas
  4. Creating record with correct values with each line read in from file
  5. Calling InsertIntoHash() with each record they have created
  6. Exception handling for opening and reading from file with appropriate catch and output

Visual Basic (VB.NET)

Sub CreateHashTable()
     Dim Line As String
     Dim Data(3) As String
     Dim TheRecord As NewRecord
     Try
         Dim FileReader As New System.IO.StreamReader("HashData.txt")
         While Not FileReader.EndOfStream
             Line = FileReader.ReadLine()
             Data = Split(Line, ",")
             TheRecord.Key = Integer.Parse(Data(0))
             TheRecord.Item1 = Integer.Parse(Data(1))
             TheRecord.Item2 = Integer.Parse(Data(2))
             InsertIntoHash(TheRecord)
         End While
         FileReader.Close()
     Catch ex As Exception
         Console.WriteLine("Cannot open file")
     End Try
 End Sub

Python

def CreateHashTable():
      global HashTable
      global Spare
      try:
          File = open("HashData.txt")
          for Line in File:
             Data = Line.strip()
             Data = Line.split(",")
             InsertIntoHash(Record(int(Data[0]), int(Data[1]), int(Data[2])))
          File.close()
      except:
          print("Cannot open file")

 University Press & Assessment 2025                       Page 29 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme          May/June 2025

Mark points

  • Procedure header (and end where appropriate), opening and closing file HashData.txt
  • Reading in all lines of data …
  • … splitting each line by commas
  • Creating record with correct values with each line read in from file
  • Calling InsertIntoHash() with each record they have created
  • Exception handling for opening and reading from file with appropriate catch and output

Part 2(f)(i) — solution

  1. Procedure header (and end where appropriate) and looping through each element in Spare …
  2. … checking if record is empty and outputting key field if not empty

Visual Basic (VB.NET)

Sub PrintSpare()
    Dim X As Integer = 0
    While Spare(X).Key <> -1
        Console.WriteLine(Spare(X).Key)
        X = X + 1
    End While
 End Sub

Python

def PrintSpare():
      global Spare
      X = 0
      while Spare[X].GetKey() != -1:
          print(Spare[X].GetKey())
          X +=1

 University Press & Assessment 2025                       Page 30 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Procedure header (and end where appropriate) and looping through each element in Spare …
  • … checking if record is empty and outputting key field if not empty

Part 2(f)(ii) — solution

1 mark for calling Initialise() then CreateHashTable() then PrintSpare() 1 Example program code: VB.NET Initialise() CreateHashTable() PrintSpare() Python Initialise() CreateHashTable() PrintSpare() University Press & Assessment 2025 Page 31 of 45 9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025

Visual Basic (VB.NET)

Initialise()
 CreateHashTable()
 PrintSpare()

Python

Initialise()
 CreateHashTable()
 PrintSpare()

 University Press & Assessment 2025                       Page 31 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Include the ideas shown in the solution above.

Part 2(f)(iii) — solution

1 mark for output 1 For example: University Press & Assessment 2025 Page 32 of 45 9618/42 Cambridge International AS & A Level – Mark Scheme May/June 2025

Mark points

  • Include the ideas shown in the solution above.

Question 3

Paper page 9 for Q3
Original paper page 9

Part 3(a)(i) — solution

  1. Class header (and end when appropriate)
  2. Four attributes with appropriate data types
  3. Constructor header (and end where appropriate) within class taking (min) 4 parameters …
  4. … assigning each parameter to its attribute

Visual Basic (VB.NET)

Class Animal
     Public Name As String
     Public Sound As String
     Public Size As Integer
     Public Intelligence As Integer

     Sub New(pName, pSound, pSize, pIntelligence)
         Name = pName
         Sound = pSound
         Size = pSize
         Intelligence = pIntelligence
     End Sub
 End Class

 University Press & Assessment 2025                       Page 34 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Python

class Animal:
      def __init__(self, pName, pSound, pSize, pIntelligence):
          self.Name = pName #string
          self.Sound = pSound #string
          self.Size = pSize #integer
          self.Intelligence = pIntelligence #integer

 University Press & Assessment 2025                       Page 35 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Class header (and end when appropriate)
  • Four attributes with appropriate data types
  • Constructor header (and end where appropriate) within class taking (min) 4 parameters …
  • … assigning each parameter to its attribute

Part 3(a)(ii) — solution

  1. Description() method header (and end where appropriate) with no parameter
  2. Concatenating the attributes with the given message …
  3. … and returning the created message

Visual Basic (VB.NET)

Function Description()
     Dim Message As String = "The animal's name is " & Name & ", it makes a " & Sound & ", its size is " &
 CStr(Size) & " and its intelligence level is " & CStr(Intelligence)
     Return Message
 End Function

Python

def Description(self):
         Message = "The animal's name is " + self.Name + ", it makes a " + self.Sound + ", its size is " +
 str(self.Size) + " and its intelligence level is " + str(self.Intelligence)
         return Message

 University Press & Assessment 2025                       Page 36 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme                               May/June 2025

Mark points

  • Description() method header (and end where appropriate) with no parameter
  • Concatenating the attributes with the given message …
  • … and returning the created message

Part 3(b)(i) — solution

  1. Class header (and end where appropriate) inherits from Animal
  2. Constructor header (and end where appropriate) taking 6 parameters within class and calling parent constructor with
  3. … WingSpan and NumberWords attributes defined with data types and parameters assigned within constructor
  4. ChangeNumberWords() method header (and end where appropriate) takes one parameter and adds parameter to

Visual Basic (VB.NET)

Class Parrot
     Inherits Animal
     Dim WingSpan As Integer
     Dim NumberWords As Integer
     Sub New(pName, pSound, pSize, pIntelligence, pWingSpan, pNumberWords)
         MyBase.New(pName, pSound, pSize, pIntelligence)
         WingSpan = pWingSpan
         NumberWords = pNumberWords
     End Sub

 University Press & Assessment 2025                       Page 37 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

     Sub ChangeNumberWords(Change)
         NumberWords = NumberWords + Change
     End Sub
 End Class

Python

class Parrot(Animal):
      def __init__(self, pName, pSound, pSize, pIntelligence, pWingSpan, pNumberWords):
          super().__init__(pName, pSound, pSize, pIntelligence)
          self.WingSpan = pWingSpan #integer
          self.NumberWords = pNumberWords #integer

        def ChangeNumberWords(self, Change):
            self.NumberWords = self.NumberWords + Change

 University Press & Assessment 2025                       Page 38 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Class header (and end where appropriate) inherits from Animal
  • Constructor header (and end where appropriate) taking 6 parameters within class and calling parent constructor with
  • … WingSpan and NumberWords attributes defined with data types and parameters assigned within constructor
  • ChangeNumberWords() method header (and end where appropriate) takes one parameter and adds parameter to

Part 3(b)(ii) — solution

  1. Description() method header (and end where appropriate) taking no parameters and
  2. Concatenating and returning the correct string

Visual Basic (VB.NET)

Overloads Function Description()
    Dim Message As String = "The animal's name is " & Name & ", it makes a " & Sound & ", its size is " &
 CStr(Size) & " and its intelligence level is " & CStr(Intelligence) & ". It has a wingspan of " &
 CStr(WingSpan) & "cm and can say " & CStr(NumberWords) & " words."
     Return Message
 End Function

Python

def Description(self):
         Message = "The animal's name is " + self.Name + ", it makes a " + self.Sound + ", its size is " +
 str(self.Size) + " and its intelligence level is " + str(self.Intelligence) + ". It has a wingspan of " +
 str(self.WingSpan) + "cm and can say " + str(self.NumberWords) + " words."
         return Message

 University Press & Assessment 2025                       Page 39 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme                               May/June 2025

Mark points

  • Description() method header (and end where appropriate) taking no parameters and
  • Concatenating and returning the correct string

Part 3(c)(i) — solution

  1. Class header (and end where appropriate) inherits from Animal
  2. Constructor header (and end where appropriate) taking 5 parameters within class and calling parent constructor with
  3. Attribute Territory defined as int and parameter assigned within constructor
  4. SetTerritory() method header (and end) takes 1 parameter and adds parameter to attribute TerritorySize

Visual Basic (VB.NET)

Class Wolf
     Inherits Animal
     Dim TerritorySize As Integer
     Sub New(pName, pSound, pSize, pIntelligence, pTerritory)
         MyBase.New(pName, pSound, pSize, pIntelligence)
         TerritorySize = pTerritory
     End Sub

     Sub SetTerritorySize(Change)
         TerritorySize = TerritorySize + Change
     End Sub
 End Class

 University Press & Assessment 2025                       Page 40 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Python

class Wolf(Animal):
      def __init__(self, pName, pSound, pSize, pIntelligence, pTerritorySize):
          super().__init__(pName, pSound, pSize, pIntelligence)
          self.TerritorySize = pTerritorySize #integer
      def SetTerritorySize(self, Change):
          self.TerritorySize = self.TerritorySize + Change

 University Press & Assessment 2025                       Page 41 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Class header (and end where appropriate) inherits from Animal
  • Constructor header (and end where appropriate) taking 5 parameters within class and calling parent constructor with
  • Attribute Territory defined as int and parameter assigned within constructor
  • SetTerritory() method header (and end) takes 1 parameter and adds parameter to attribute TerritorySize

Part 3(c)(ii) — solution

  1. Description() method header (and end where appropriate) taking no parameters and
  2. Concatenating and return correct message

Visual Basic (VB.NET)

Overloads Function Description()
     Dim Message As String = "The animal's name is " & Name & ", it makes a " & Sound & ", its size is " &
 CStr(Size) & " and its intelligence level is " & CStr(Intelligence) + ". Its territory is " &
 CStr(TerritorySize) & " square miles."
     Return Message
 End Function

Python

def Description(self):
         Message = "The animal's name is " + self.Name + ", it makes a " + self.Sound + ", its size is " +
 str(self.Size) + " and its intelligence level is " + str(self.Intelligence) + " it's territory is " +
 str(self.TerritorySize) +" square miles."
         return Message

 University Press & Assessment 2025                       Page 42 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Description() method header (and end where appropriate) taking no parameters and
  • Concatenating and return correct message

Part 3(d)(i) — solution

  1. 1 correct instance created and stored in a suitable variable/structure
  2. 2nd and 3rd correct instances created and stored in a suitable variable/structure

Visual Basic (VB.NET)

Dim Animal1 As Parrot
 Animal1 = New Parrot("Chewie", "Squawk", 1, 10, 30, 29)
 Dim Animal2 As Wolf
 Animal2 = New Wolf("Nighteyes", "Howl", 8, 7, 100)
 Dim Animal3 As Animal
 Animal3 = New Animal("Copper", "Neigh", 10, 6)

Python

Animal1 = Parrot("Chewie","Squawk",1,10,30,29)
 Animal2 = Wolf("Nighteyes","Howl",8,7,100)
 Animal3 = Animal("Copper", "Neigh", 10, 6)

 University Press & Assessment 2025                        Page 43 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme          May/June 2025

Mark points

  • 1 correct instance created and stored in a suitable variable/structure
  • 2nd and 3rd correct instances created and stored in a suitable variable/structure

Part 3(d)(ii) — solution

  1. Calling SetTerritorySize(-20) for instance of Nighteyes
  2. Calling ChangeNumberWords(2) for instance of Chewie
  3. Calling Description() for all 3 animals (after any updates) and outputting return values

Visual Basic (VB.NET)

Animal2.SetTerritorySize(-20)
 Animal1.ChangeNumberWords(2)
 Console.WriteLine(Animal1.Description())
 Console.WriteLine(Animal2.Description())
 Console.WriteLine(Animal3.Description())

Python

Animal2.SetTerritorySize(-20)
 Animal1.ChangeNumberWords(2)
 print(Animal1.Description())
 print(Animal2.Description())
 print(Animal3.Description())

 University Press & Assessment 2025                       Page 44 of 45

9618/42                                          Cambridge International AS & A Level – Mark Scheme   May/June 2025

Mark points

  • Calling SetTerritorySize(-20) for instance of Nighteyes
  • Calling ChangeNumberWords(2) for instance of Chewie
  • Calling Description() for all 3 animals (after any updates) and outputting return values

Part 3(d)(iii) — solution

  1. All three messages accurate with all relevant values
  2. … showing correctly updated territory for Nighteyes and words for Chewie

Mark points

  • All three messages accurate with all relevant values
  • … showing correctly updated territory for Nighteyes and words for Chewie