Evidence Python

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

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

Candidate Name: [Enter your name here]


Centre Number: [Enter your centre number here]
Candidate Number: [Enter your candidate number here]

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)
DataArray = []

with open("Data.txt", 'r') as inputFile:


for i in range(25):
DataArray.append(int(inputFile.readline().strip()))

Part 1(a)(ii)
DataArray = []

with open("Data.txt") as inputFile:


for item in inputFile:
DataArray.append(item.strip())

Part 1(b)(i)
def printArray(list):
for item in list:
print(item)

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

Candidate Name: [Enter your name here]


Centre Number: [Enter your centre number here]
Candidate Number: [Enter your candidate number here]

Part 1(b)(ii)
def printArray(list):
for item in list:
print(item)

DataArray = []

with open("Data.txt") as inputFile:


for item in inputFile:
DataArray.append(item.strip())

printArray(DataArray)

Part 1(b)(iii)
{Copy and paste the screenshot for Question 1(b)(iii) here}

Part 1(c)
def LinearSearch(list, target):

count = 0

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

Candidate Name: [Enter your name here]


Centre Number: [Enter your centre number here]
Candidate Number: [Enter your candidate number here]

for item in list:


if item == target:
count += 1
return count

Part 1(d)(i)
DataArray = []

with open("Data.txt") as inputFile:


for item in inputFile:
DataArray.append(int(item.strip()))

def LinearSearch(list, target):

count = 0

for item in list:


if item == target:
count += 1
return count

inputNumber = int(input("Input a whole number between 0 and 100 inclusive:


"))

while inputNumber > 100 or inputNumber < 0:


inputNumber = int(input("Input a whole number between 0 and 100
inclusive: "))

foundCount = LinearSearch(DataArray, inputNumber)

print(f"The number {inputNumber} is found {foundCount} times. ")

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

Candidate Name: [Enter your name here]


Centre Number: [Enter your centre number here]
Candidate Number: [Enter your candidate number here]

Part 1(d)(ii)

You might also like