You are on page 1of 7

9618 Paper 43 – AS & A Level Computer Science evidence document

Candidate Name: MD Talha Hossain Khan


Centre Number: Elites
Candidate Number: 0

Screenshots or program listings must be copied into appropriate cells in the following table.

Save this evidence document as evidence_ followed by your centre number_ candidate number,
for example, evidence_ zz999_9999 and insert your name, centre number and candidate number
into the header above.

Examiners must be able to read the contents including any screenshots without the use of a
magnifying glass. Answers that are not readable or are missing will not be awarded any marks.

Save this evidence document at regular intervals, for example every 10 minutes.

Question 1
Part 1(a)(i)
#DECLARE DataArray : ARRAY[0:24] OF INTEGER
DataArray = []

Part 1(a)(ii)
file = open("Data.txt", "r")

for line in file:


temp = line.strip()
DataArray.append(temp)
file.close()

Part 1(b)(i)
def PrintArray(IntArray):
Output = ""
for Count in range(len(IntArray)):
Output = Output + str(IntArray[Count]) + " "
print(Output)

Part 1(b)(ii)
PrintArray(DataArray)

Part 1(b)(iii)

1
9618 Paper 43 – AS & A Level Computer Science evidence document

Candidate Name: MD Talha Hossain Khan


Centre Number: Elites
Candidate Number: 0

Part 1(c)
def LinearSearch(Array, Search):
found = 0

for Count in range(len(Array)):


if int(Array[Count]) == Search:
found = found + 1

return found

Part 1(d)(i)
InputVal = int(input("Input number between 0 and 100 "))

while InputVal < 0 or InputVal > 100:


print("Error Try Again")
InputVal = int(input("Input number between 0 and 100 "))

NumTimes = LinearSearch(DataArray,InputVal)

print("The number", InputVal, "is found", NumTimes, "times")

Part 1(d)(ii)

Question 2
Part 2(a)(i)
class Vehicle():
#PRIVATE ID : STRING
#PRIVATE MaxSpeed : INTEGER
#PRIVATE CurrentSpeed : INTEGER
#PRIVATE IncreaseAmount : INTEGER
#PRIVATE HorizontalPosition : INTEGER

def __init__(Self, I, Max, Inc):


Self.__ID = I
Self.__MaxSpeed = int(Max)
Self.__CurrentSpeed = 0
Self.__IncreaseAmount = int(Inc)
Self.__HorizontalPosition = 0

2
9618 Paper 43 – AS & A Level Computer Science evidence document

Candidate Name: MD Talha Hossain Khan


Centre Number: Elites
Candidate Number: 0

Part 2(a)(ii)
def GetCurrentSpeed(Self):
return Self.__CurrentSpeed

def GetMaxSpeed(Self):
return Self.__MaxSpeed

def GetIncreaseAmount(Self):
return Self.__IncreaseAmount

def GetHorizontalPosition(Self):
return Self.__HorizontalPosition

Part 2(a)(iii)
def SetCurrentSpeed(Self, SetVal):
Self.__CurrentSpeed = SetVal

def SetHorizontalPosition(Self, SetHoz):


Self.__HorizontalPosition = SetHoz

Part 2(a)(iv)
def IncreaseSpeed(Self):
Self.__CurrentSpeed = Self.__CurrentSpeed + Self.__IncreaseAmount

if Self.__CurrentSpeed > Self.__MaxSpeed:


Self.__CurrentSpeed = Self.__MaxSpeed

Self.__HorizontalPosition = Self.__HorizontalPosition + Self.__CurrentSpeed

Part 2(b)(i)
class Helicopter(Vehicle):
#PRIVATE VerticalPosition : INTEGER
#PRIVATE VerticalChange : INTEGER
#PRIVATE MaxHeight : INTEGER

def __init__(Self, I, Max, Inc, Vc, Mh):


super().__init__(I, Max, Inc)
Self.__VerticalPosition = 0
Self.__VerticalChange = int(Vc)
Self.__MaxHeight = int(Mh)

Part 2(b)(ii)

3
9618 Paper 43 – AS & A Level Computer Science evidence document

Candidate Name: MD Talha Hossain Khan


Centre Number: Elites
Candidate Number: 0

def IncreaseSpeed(Self):
Self.__VerticalPosition = Self.__VerticalPosition + Self.__VerticalChange

if Self.__VerticalPosition > Self.__MaxHeight:


Self.__VerticalPosition = Self.__MaxHeight

Vehicle.SetCurrentSpeed(Self, (Vehicle.GetCurrentSpeed(Self) +
Vehicle.GetIncreaseAmount(Self)))

if Vehicle.GetCurrentSpeed(Self) > Vehicle.GetMaxSpeed(Self):


Vehicle.SetCurrentSpeed(Self, Vehicle.GetMaxSpeed(Self))

Vehicle.SetHorizontalPosition(Self, (Vehicle.GetCurrentSpeed(Self) +
Vehicle.GetHorizontalPosition(Self)))

Part 2(c)
def Output(Self):
print("Horizontal Position is", Self.__HorizontalPosition)
print("Speed is", Self.__CurrentSpeed)

def Output(Self):
print("Horizontal Position is", Vehicle.GetHorizontalPosition(Self))
print("Speed is", Vehicle.GetCurrentSpeed(Self))
print("Vertical Position is", Self.__VerticalPosition)

Part 2(d)(i)
Car = Vehicle("Tiger", 100, 20)
Car.IncreaseSpeed()
Car.IncreaseSpeed()
Car.Output()

Helicop = Helicopter("Lion", 350, 40, 3, 100)


Helicop.IncreaseSpeed()
Helicop.IncreaseSpeed()
Helicop.Output()

Part 2(d)(ii)

4
9618 Paper 43 – AS & A Level Computer Science evidence document

Candidate Name: MD Talha Hossain Khan


Centre Number: Elites
Candidate Number: 0

Question 3
Part 3(a)
#DECLARE Animal : ARRAY[0:19] OF STRING
#DECLARE Colour : ARRAY[0:9] OF STRING
global Animal
global Colour

Animal = []
Colour = []

AnimalTopPointer = 0
ColourTopPointer = 0

Part 3(b)(i)
def PushAnimal(DataToPush):
global Animal
global AnimalTopPointer

if AnimalTopPointer > 19:


return False
else:
Animal[AnimalTopPointer] = DataToPush
AnimalTopPointer = AnimalTopPointer + 1
return True

Part 3(b)(ii)
def PopAnimal():
global Animal
global AnimalTopPointer

#DELARE ReturnData : STRING

if AnimalTopPointer == 0:
return ""
else:
ReturnData = Animal[AnimalTopPointer - 1]
AnimalTopPointer = AnimalTopPointer - 1
return ReturnData

Part 3(b)(iii)
def ReadData():
try:
5
9618 Paper 43 – AS & A Level Computer Science evidence document

Candidate Name: MD Talha Hossain Khan


Centre Number: Elites
Candidate Number: 0

file = open("AnimaData.txt", "r")


for line in file:
temp = line.strip()
PushAnimal(temp)
file.close()

except IOError:
print("File not found")

Part 3(b)(iv)
def PushColour(DataToPush):
global Colour
global ColourTopPointer

if ColourTopPointer > 9:
return False
else:
Colour.append(DataToPush)
ColourTopPointer = ColourTopPointer + 1
return True

def PopColour():
global Colour
global ColourTopPointer

#DELARE ReturnData : STRING

if ColourTopPointer == 0:
return ""
else:
ReturnData = Colour[ColourTopPointer - 1]
ColourTopPointer = ColourTopPointer - 1
return ReturnData

Part 3(b)(v)
def ReadData():
try:
fileAnimal = open("AnimalData.txt", "r")
for line in fileAnimal:
temp = line.strip()
PushAnimal(temp)
fileAnimal.close()

fileColour = open("ColourData.txt", "r")


for line in fileColour:
temp = line.strip()
PushColour(temp)
fileColour.close()

6
9618 Paper 43 – AS & A Level Computer Science evidence document

Candidate Name: MD Talha Hossain Khan


Centre Number: Elites
Candidate Number: 0

except IOError:
print("File not found")

Part 3(c)
def OutputItem():
TempAnimal = PopAnimal()
TempColour = PopColour()
print(TempColour, TempAnimal)

if TempColour == "":
PushAnimal(TempAnimal)
print("No colour")

if TempAnimal == "":
PushColour(TempColour)
print("No animal")

Part 3(d)(i)
ReadData()
for count in range(4):
OutputItem()

Part 3(d)(ii)

You might also like