Cambridge International AS & A Level: Computer Science 9618/42
Cambridge International AS & A Level: Computer Science 9618/42
Cambridge International AS & A Level: Computer Science 9618/42
com
Published
This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge International will not enter into discussions about these mark schemes.
Cambridge International is publishing the mark schemes for the October/November 2023 series for most
Cambridge IGCSE, Cambridge International A and AS Level components, and some Cambridge O Level
components.
These general marking principles must be applied by all examiners when marking candidate answers. They should be applied alongside the
specific content of the mark scheme or generic level descriptors for a question. Each question paper and mark scheme will also comply with these
marking principles.
• the specific content of the mark scheme or the generic level descriptors for the question
• the specific skills defined in the mark scheme or in the generic level descriptors for the question
• the standard of response required by a candidate as exemplified by the standardisation scripts.
Marks awarded are always whole marks (not half marks, or other fractions).
• marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit is given for valid answers which go beyond
the scope of the syllabus and mark scheme, referring to your Team Leader as appropriate
• marks are awarded when candidates clearly demonstrate what they know and can do
• marks are not deducted for errors
• marks are not deducted for omissions
• answers should only be judged on the quality of spelling, punctuation and grammar when these features are specifically assessed by the
question as indicated by the mark scheme. The meaning, however, should be unambiguous.
Rules must be applied consistently, e.g. in situations where candidates have not followed instructions or in the application of generic level
descriptors.
Marks should be awarded using the full range of marks defined in the mark scheme for the question (however; the use of the full mark range may
be limited according to the quality of the candidate responses seen).
Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should not be awarded with grade thresholds or
grade descriptors in mind.
Java
VB.NET
Python
Java
VB.NET
Python
• Procedure PushData() heading (and end where appropriate) taking one parameter
Java
1(b)(i) VB.NET
Sub PushData(Letter As Char)
If Letter = "a" Or Letter = "e" Or Letter = "i" Or Letter = "o" Or Letter = "u" Then
If VowelTop = 100 Then
Console.WriteLine("Vowel stack full")
Else
StackVowel(VowelTop) = Letter
VowelTop += 1
End If
Else
If ConsonantTop = 100 Then
Console.WriteLine("Consonant stack full")
Else
StackConsonant(ConsonantTop) = Letter
ConsonantTop += 1
End If
End If
End Sub
Python
def PushData(Letter):
global VowelTop
global ConsonantTop
if Letter == "a" or Letter == "e" or Letter == "i" or Letter == "o" or Letter == "u":
if VowelTop == 100:
print("Vowel stack full")
else:
StackVowel.append(Letter)
VowelTop = VowelTop + 1
else:
if ConsonantTop == 100:
print("Consonant stack full")
else:
StackConsonant.append(Letter)
ConsonantTop = ConsonantTop + 1
Java
VB.NET
Sub ReadData()
Try
Dim DataReader As New System.IO.StreamReader("StackData.txt")
Do Until DataReader.EndOfStream
PushData(DataReader.ReadLine())
Loop
DataReader.Close()
© UCLES 2023 Page 8 of 34
9618/42 Cambridge International AS & A Level – Mark Scheme www.dynamicpapers.com
October/November 2023
PUBLISHED
Question Answer Marks
End Sub
Python
def ReadData():
try:
DataFile = open("StackData.txt")
for Line in DataFile:
PushData(Line.strip())
DataFile.close()
except:
print("File not found")
Java
1(c) VB.NET
Function PopVowel()
If VowelTop - 1 >= 0 Then
VowelTop -= 1
Dim DataToReturn As Char = StackVowel(VowelTop)
Return DataToReturn
Else
Return "No data"
End If
End Function
Function PopConsonant()
If ConsonantTop - 1 >= 0 Then
ConsonantTop -= 1
Dim DataToReturn As Char = StackConsonant(ConsonantTop)
Return DataToReturn
Else
Return "No data"
End If
End Function
Python
def PopVowel():
global VowelTop
global ConsonantTop
if VowelTop - 1 >= 0:
VowelTop = VowelTop - 1
DataToReturn = StackVowel[VowelTop]
del StackVowel[-1]
return DataToReturn
else:
return "No data"
Java
VB.NET
1(d)(i) End If
ElseIf Choice = "consonant" Then
DataAccessed = PopConsonant()
If DataAccessed <> "No data" Then
Letters = Letters & DataAccessed
Flag = True
Else
Console.WriteLine("No consonants left")
End If
End If
End While
Next
Console.WriteLine(Letters)
End Sub
Python
#main
VowelTop = 0
ConsonantTop = 0
ReadData()
Letters = ""
Flag = False
print(Letters)
1(d)(ii) One mark showing input in order vowel, cons, cons, vowel, vowel. Output is then utxoe 1
e.g.
Java
public static Integer IterativeCalculate(Integer Number){
Integer ToFind = Number;
Integer Total = 0;
while(Number != 0){
if(ToFind % Number == 0){
Total += Number;
}
Number--;
}
return Total;
}
VB.NET
Function IterativeCalculate(Number As Integer)
Dim total As Integer = 0
Dim ToFind As Integer = Number
While Number <> 0
If ToFind Mod Number = 0 Then
total = total + Number
End If
Number = Number - 1
End While
Return total
End Function
2(a)(i) Python
def IterativeCalculate(Number):
Total = 0
ToFind = Number
while Number != 0:
if ToFind % Number == 0:
Total = Total + Number
Number = Number - 1
return Total
Java
System.out.println(IterativeCalculate(10));
VB.NET
Sub Main(args As String())
Console.WriteLine(IterativeCalculate(10))
End Sub
Python
print(IterativeCalculate(10))
Java
2(b)(i) VB.NET
Python
Java
System.out.println(RecursiveValue(50,50));
VB.NET
Console.WriteLine(RecursiveValue(50,50))
Python
print(RecursiveValue(50,50))
Java
class Character{
private String CharacterName;
private Date DateOfBirth;
private Double Intelligence;
private Integer Speed;
VB.NET
Class Character
Private CharacterName As String
Private DateOfBirth As Date
Private Intelligence As Single
Private Speed As Integer
Python
class Character:
#self.__CharacterName string
#self.__DateOfBirth date
#self.__Intelligence real
#self.__Speed integer
Java
VB.NET
Function GetIntelligence()
Return Intelligence
End Function
Function GetName()
Return CharacterName
End Function
Python
def GetIntelligence(self):
return self.__Intelligence
def GetName(self):
return self.__CharacterName
Java
VB.NET
Sub SetIntelligence(NewValue)
Intelligence = NewValue
End Sub+
Python
3(a)(iv) One mark for method multiplying attribute intelligence by 1.1 (or equivalent) and storing in attribute. 1
Java
VB.NET
Python
def Learn(self):
self.__Intelligence = self.__Intelligence * 1.1
Java
VB.NET
Function ReturnAge()
Return DateDiff(DateInterval.Year, DateOfBirth, #01/01/2023#)
End Function
Python
def ReturnAge(self):
return 2023 - self.__DateOfBirth.year
Java
VB.NET
Python
Java
FirstCharacter.Learn();
System.out.println(FirstCharacter.GetName() + " is " + FirstCharacter.ReturnAge() + " years
old and has intelligence " + FirstCharacter.GetIntelligence());
VB.NET
FirstCharacter.Learn()
Console.WriteLine(FirstCharacter.GetName() & " is " & FirstCharacter.ReturnAge() &
" years old and has intelligence " & FirstCharacter.GetIntelligence())
Python
FirstCharacter.Learn()
print(FirstCharacter.GetName(), "is", FirstCharacter.ReturnAge(), "years old and has
intelligence" , FirstCharacter.GetIntelligence())
3(b(iii) One mark for screenshot with Royal, 4 years, 77 intelligence e.g. 1
Java
VB.NET
Class MagicCharacter
Inherits Character
Private Element As String
Sub New(ElementP, CName, DBirth, Intell, SpeedP)
MyBase.New(CName, DBirth, Intell, SpeedP)
Element = ElementP
End Sub
End Class
3(c)(i) Python
class MagicCharacter(Character):
#self.__Element String
Java
VB.NET
End Sub
3(c)(ii) Python
def Learn(self):
if(self.__Element == "fire" or self.__Element == "water"):
super().SetIntelligence(super().GetIntelligence() * 1.2)
elif self.__Element == "earth":
super().SetIntelligence(super().GetIntelligence() * 1.3)
else:
super().SetIntelligence(super().GetIntelligence() * 1.1)
Java
MagicCharacter FirstMagic = new MagicCharacter("fire", "Light", new Date(2018,03,03), 75.0,
22);
VB.NET
Dim FirstMagic As MagicCharacter
FirstMagic = New MagicCharacter("fire", "Light", #3/3/2018#, 75, 22)
Python
FirstMagic = MagicCharacter("fire", "Light", datetime.datetime(2018, 3, 3), 75, 22)
3(d)(ii) One mark for calling Learn() for FirstMagic and outputting all required data in appropriate message using gets. 1
Java
FirstMagic.Learn();
System.out.println(FirstMagic.GetName() + " is " + FirstMagic.ReturnAge() + " years old and
has intelligence " + FirstMagic.GetIntelligence());
VB.NET
FirstMagic.Learn()
Console.WriteLine(FirstMagic.GetName() & " is " & FirstMagic.ReturnAge() & " years old and
has intelligence " & FirstMagic.GetIntelligence())
Python
FirstMagic.Learn()
print(FirstMagic.GetName(), "is", FirstMagic.ReturnAge(), "years old and has intelligence",
FirstMagic.GetIntelligence())