0% found this document useful (0 votes)
98 views28 pages

Computer Science 2024 Mock

The document outlines the Pre-Leaving Certificate Examination for Computer Science, including details about the exam structure, sections, and instructions for candidates. It consists of three sections: Short Answer Questions (Section A), Long Questions (Section B), and Programming (Section C), with specific marks allocated to each. Candidates are instructed on how to answer questions and the use of materials during the exam.

Uploaded by

northernsnowdog
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views28 pages

Computer Science 2024 Mock

The document outlines the Pre-Leaving Certificate Examination for Computer Science, including details about the exam structure, sections, and instructions for candidates. It consists of three sections: Short Answer Questions (Section A), Long Questions (Section B), and Programming (Section C), with specific marks allocated to each. Candidates are instructed on how to answer questions and the use of materials during the exam.

Uploaded by

northernsnowdog
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

*P51*

Pre-Leaving Certiϐicate Examination 2024

Computer Science
Sections A & B
Higher Level

Time: 1 hour, 30 minutes


123 marks

Name:
School:
Address:
Class:
Teacher:

For Examiner use only


SecƟon QuesƟon Mark SecƟon QuesƟon Mark SecƟon QuesƟon Mark
1 7 13
2 8 B 14
3 9 15
A A
4 10 SecƟon B Total:
5 11 C 16
6 12 SecƟon C Total:
SecƟon A Total: Total:
Instructions

There are three sec ons in this examina on. Sec on A and B appear in this booklet. Sec on C is in
a separate booklet that will be provided for the computer-based element.

SecƟon A Short Answer Ques ons A empt any nine ques ons 45 marks
All ques ons carry equal marks

SecƟon B Long Ques ons A empt any two ques ons 78 marks
All ques ons carry equal marks

SecƟon C Programming Answer all ques on parts 87 marks

Calculators may not be used during this sec on of the examina on

The superintendent will give you a copy of page 78 (Logic gates) of the Formulae and Tables
booklet on request. You are not allowed to bring your own copy into the examina on.

Write your answers for Sec on A and Sec on B in the spaces provided in this booklet. There is
space for extra work at the end of the booklet. Label any such extra work clearly with the ques on
number and part.

2
Section A Short Answer Questions 45 marks

Answer any nine ques ons.

QuesƟon 1

Please study the code carefully and then answer the following ques on.

Given the following six lines of code from a program, for each line, fill in the value stored in the
variable answer.

1 answer = 7
2 name = “Robin”
3 answer += 1
4 name = answer
5 answer = “Charlie”
6 answer = name

Lines of Python code Value stored in “answer” at each line

answer = 7

name =”Robin”

answer += 1

name = answer

answer = “Charlie”

answer = name

QuesƟon 2

Briefly describe one problem that can be solved using heuris cs and why it needs a heuris c
approach to be solved.

3
QuesƟon 3

The following code was intended to replace any nega ve numbers in a list with the value 0.

1 myList = [1, 2, 3, 4, -5, 6]


2
3 for item in myList:
4 if item < 0:
5 item = 0
6
7 print (myList)

However, the above code does not work, prin ng out the result:

[1, 2, 3, 4, -5, 6]

Explain why the code did not work as intended.

4
QuesƟon 4

Tes ng is used in so ware development. The below code was intended to replace any nega ve
numbers in a list with the value 0, but instead it outputs [1, 2, 3, 4, -5, 6], not changing
the nega ve values as intended.

1 myList = [1, 2, 3, 4, -5, 6]


2
3 for item in myList:
4 if item < 0:
5 item = 0
6
7 print (myList)

Explain how you might test the above code to iden fy the errors in the program.

QuesƟon 5

Describe what a unit test is, and how it differs from a system test.

5
QuesƟon 6

The list below contains 100,000 integers. Only the first six items in the list are shown.

myList = [1, 2, 3, 4, -5, 6, ...]

(a) Why would you not present the data in the above form to someone that wants to find the
number of items in the list that are nega ve?

(b) Name one graphical form that would be suitable for presen ng the data in the list, and one
graphical form that would be unsuitable and why (for each form).

6
QuesƟon 7

Below is the code of a sor ng algorithm:

myList = [9, 10, 30, 19, 3]

for index in range(1, len(myList)):


itemToInsert = myList[index]
position = index
while position > 0 and myList[position-1] > itemToInsert:
myList[position] = myList[position-1]
myList[position-1] = itemToInsert
position -= 1

(a) Name the sor ng algorithm.

(b) What is the me complexity for the worst-case scenario for this algorithm?

7
QuesƟon 8

Agent-based modelling is an effec ve modelling tool for certain scenarios.

(a) Name a scenario that agent-based modelling can be used for.

(b) Explain the benefits of using agent-based modelling for your example named above.

QuesƟon 9

Below are two rela onal tables in a database.

ID FName SName Year


1 Keith Quille 1
2 Roisin Faherty 2
3 Karen Nolan 3
Year Tutors

ID Year_Tutor_ID FName SName


1 3 Charlie Quille
2 2 Robin Quille
Students

8
Describe the rela onal rela onship between the tables above.

QuesƟon 10

Below is an extract from a US Na onal Cancer Ins tute post tled 'Can Ar ficial Intelligence Help
See Cancer in New, and Be er, Ways?' (2022). Read the extract carefully and answer the ques on
that follows.

“Two iden cal black-and-white pictures of murky shapes sit side-by-side on a computer screen. On
the le side, Ismail Baris Turkbey, M.D., a radiologist with 15 years of experience, has outlined an
area where the fuzzy shapes represent what he believes is a creeping, growing prostate cancer. On
the other side of the screen, an ar ficial intelligence (AI) computer program has done the same —
and the results are nearly iden cal.”

Name and describe one ethical considera on and proposed ac on that you think should be
applied if we are to use AI in the medical domain for predic ng cancer.

9
QuesƟon 11

Websites are typically not as adap ve as they should be to allow for inclusive use for users with
special/addi onal needs. Name and describe two elements or design features that you would
implement in a website to support users with addi onal needs.

1.

2.

QuesƟon 12

The below code uses the mean func on from the sta s cs module to find the mean in a list:

myList = [1, 2, 3, 4, 5]
median = statistics.mean(myList)
print(median)

Pa ern recogni on is the ability to recognise common approaches (such as code) or pa erns
within problems you are trying to solve. When you break down (decompose) a problem into
smaller subproblems, you may be able to spot pa erns/previous code approaches that will help
you to solve the problem (adapted from Isaac Computer Science).

Iden fy one pa ern and explain its use if you were to write the code for the statistics.mean
func on yourself.

10
Section B Long Questions 78 marks

Answer any two ques ons.

QuesƟon 13

(a) What is a recursive algorithm?

(b) Recursion is slower computa onally than solving the same problem using a loop, yet
recursion is o en the preferred method over a loop for some algorithms such as the
quicksort algorithm, why is this the case?

(c) Below is an example of a recursive func on for the quicksort algorithm. This algorithm sorts
a list in ascending order. Modify the code to sort the list in descending order. The first four
rows are completed where no modifica ons were needed.
Modified code – leave blank
Original code
if modificaƟon is not needed.
def qS(listIn): -
if len(listIn) > 1: -
pivot = listIn[-1] -
belowPiv =[] -
for item in listIn[:-1]:
if item < pivot:
belowPiv.append(item)
abovePiv =[]
for item in listIn[:-1]:
if item > pivot:
abovePiv.append(item)
return qS(belowPiv) + [pivot] +
qS(abovePiv)
else:
return(listIn)

11
QuesƟon 14

(a) The internet allows the world wide web to run on it. This happens in part due to
communica on protocols. One such set of protocols that is widely used is TCP/IP.

Explain what TCP is in the transport layer in the TCP/IP protocol stack.

TCP:

(b) IP addresses are used in the internet layer of the TCP/IP protocol stack. The following is an
example of an IP address:

192.168.0.1

(i) What is an IP address?

(ii) As the number of devices connected to the internet grows, iden fy one issue that
could arise with an IPv4 address as shown above.

12
(c) An IP address is o en used when cybercrime is inves gated. This is part of the TCP/IP stack.
How can an IP address be used in cybercrime inves ga ons?

(d) Interac ve informa on systems are o en implemented as a client server model. With
respect to data security, why is a client server model a good choice?

13
QuesƟon 15

(a) What is the difference between raw data and data transformed for analysis?

Raw data:

Transformed data:

(b) The World An -Doping Agency (WADA) state that “Blood doping is the misuse of certain
techniques and/or substances to increase one’s red blood cell mass, which allows the body
to transport more oxygen to muscles and therefore increase stamina and performance.”

Each year, athletes are tested for increased red blood cells, where the data presented in the
following histogram shows the red blood cell count on the X axis and the number of athletes
on the Y axis.

Red Blood Cell Count for Professional Athletes

Mean= 4.71
Mode= 4.87
40 Median= 4.75
Number of Athletes

30

20

10

0
4.0 4.5 5.0 5.5 6.0 6.5
Red Blood Cell Count

Figure 1

14
Do you think that some athletes were blood doping? Analyse the histogram and available
data (mean, mode and median) to support your answer.

(c) WADA would like you to develop an algorithm that automa cally detects if blood doping
has occured based on red blood cell count. By examining the graph in Figure 1, write an
algorithm in pseudocode that will detect if athletes are blood doping assuming that the red
blood cell counts are stored in a list such as the one below.
(note: the data is in a one-dimensional list called athletes_RBCB that you can reference).

List example: athletes_RBCB = [4,5.6,4.2, 6.6, 6.4, 4,1]

Hint: Loop through the list and write the pseudocode to iden fy any possible values that may
indicate blood doping.

15
(d) False predic ons are o en made by such algorithms. A False Posi ve (FP) is where an athlete
was predicted as blood doping but did not, and a False Nega ve (FN) is where an athlete was
predicted as not blood doping but was.

Briefly describe, basing your answer on ethics, which of the above predic ons (a False
Posi ve or a False Nega ve) is worse for the WADA.

16
Space for extra work.

Indicate clearly the number and part of the ques on(s) you are answering.

17
Space for extra work.

Indicate clearly the number and part of the ques on(s) your are answering.

18
Space for extra work.

Indicate clearly the number and part of the ques on(s) your are answering.

19
*P51*
*P52*

Pre-Leaving Certiϐicate Examination, 2024

Computer Science
Section C
Higher Level

Time: 1 hour
87 marks
Instructions

There is one secƟon in this paper.

SecƟon C Programming One quesƟon 87 marks


Answer all quesƟon parts.

Answer all parts of the quesƟon on your digital device.

Calculators may be used during this secƟon of the examinaƟon.

The Formulae and Tables booklet cannot be used for this secƟon of the examinaƟon.

The superintendent will give you a copy of the Python Reference Guide.

Ensure that you save your work regularly.

Save your files using the naming structure described at the beginning of each quesƟon part.

If you are unable to get some code to work correctly, you can comment out the code so that you
can proceed. The code that has been commented out will be reviewed by the examiner.

Rough work pages are provided at the end of this booklet. Please note that this work will not be
reviewed by an examiner.

At the end of the examinaƟon it is your responsibilty to ensure that you have saved all of your files
onto your external media.

2
Section C Programming 87 marks

Answer all quesƟon parts.

QuesƟon 16

(a) Surveys are common pracƟce, and analysis of such surveys is oŌen essenƟal to gain an
understanding of data collected, transforming it into informaƟon. This survey was data
collected by asking people the county they were from and their monthly rent. This was to
determine naƟonal and country average rent rates. This survey only included people from
Dublin, Kildare and Laois.

Open the program called QuesƟon16_A.py from your device.

Enter your name on line 2.

# Enter name:

county = [“Dublin”, “Laois”, “Dublin”, “Dublin”, “Dublin”, “Dublin”,


“Dublin”, “Kildare”, “Laois”, “Kildare”, “Dublin”, “Laois”, “Dublin”]

rent = [2500, 1200, 2000, 2100, 1900, 1999, 1790, 1500, 1000, 1390, 1980,
1105, 1999]

# Part i

# Part ii

print(“-”*18)
print(“{:<12}”.format(“County”)+”{:<12}”.format(“Rent €”))
print(“-”*18)
for index in range(len(county)):
print(“{:<12}”.format(county[index])+”{:<12}”.format(rent[index]))

# Part iii

# Part iv

The way the data is stored is that each index (0, 1, 2 …) in each of the two lists (county and
rent) holds corresponding data. That is, the first element of each list is a response from the
same person. The list county records their county and the list rent records how much
their monthly rent is. For any analysis in this quesƟon, you must assume that the lists could
be larger, so you must calculate all values using code, they must not be hard coded.

The program currently loops through the list and prints to the screen each survey response:

----------------------------
County Rent €
----------------------------
Dublin 2500
Laois 1200
Dublin 2000

3
Modify the program to do the following:

(i) Where Part i is a comment in the code, write code to calculate and print the total
number of survey responses that the study has collected. When the program is run, it
may look as follows:

The total people in the survey is: 13

(ii) Where Part ii is a comment in the code, write code to take in and store another
survey response from the user; you must take in their county name and monthly rent
and add them to the appropriate lists. You can assume that the user will always enter
one of the following counƟes (in the correct case, that is, first leƩer uppercase and
the rest lowercase): Dublin, Kildare and Laois. When the program is run, it may look as
follows:

Please enter your county: Laois

Please enter your monthly rent amount: 2000

(iii) Where Part iii is a comment in the code, write code to calculate and print the
average rent across all three counƟes (rounding to two decimal places).

averageRent = sum of the values / number of values.

When the program is run, it may look as follows:

Average Rent for all counties: € 1747.36

(iv) Where Part iv is a comment in the code, write code to calculate and print the
average rent for each of the three counƟes, Dublin, Kildare and Laois (rounding to two
decimal places). When the program is run, it may look as follows:

Average Rent for Dublin: € 2033.5


Average Rent for Kildare: € 1445.0
Average Rent for Laois: € 1326.25

4
(b) The infinite monkey theorem states that a monkey hiƫng keys at random on a typewriter
keyboard for an infinite amount of Ɵme will almost surely type any given text, including the
complete works of William Shakespeare.

Open the program called QuesƟon16_B.py from your device.

Enter your name on line 2.

# Enter name:

import random

targetWord = “T”

def monkeys_typing():
guessNumber = random.randint(65, 90)
letter1 = chr(guessNumber)
count = 1
guess = letter1
print(guess)

while guess != targetWord:


guessNumber = random.randint(65, 90)
letter1 = chr(guessNumber)
guess = letter1
print(guess)
count +=1
return count

print(monkeys_typing())

This monkeys_typing funcƟon is designed to return the number of Ɵmes it takes a monkey
to guess characters (mimicking the infinite monkey theorem for a limited amount of text) unƟl
it guesses the leƩer T. Please note the random number guesses the ASCII range for uppercase
leƩers and converts them to characters to compare against the desired output, the leƩer T.

Modify the program to do the following:

(i) For this part, do not modify the funcƟon, modify the main body code to run the
funcƟon three Ɵmes and get an average of how many guesses are needed to type
the leƩer T. An example output would be:

Average number of guesses for three runs is: 107.33

(ii) Modify the funcƟon to idenƟfy how many guess it may take to generate the word
“THE”, note you will also have to modify the variable: targetWord = “THE”.
An example output would be:

Average number of guesses for three runs is: 18148.0

5
Space for rough work.

This page will not be reviewed by an examiner.

6
Space for rough work.

This page will not be reviewed by an examiner.

7
*P52*

Blank Page

You might also like