Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Pearson Edexcel Level 1/Level 2 GCSE

Rating
-
Sold
-
Pages
36
Grade
A+
Uploaded on
25-10-2024
Written in
2024/2025

Exam of 36 pages for the course Pearson Edexcel Level 1/Level 2 GCSE at Pearson Edexcel Level 1/Level 2 GCSE

Institution
Course

Content preview

Pearson Edexcel Level 1/Level 2
GCSE (9–1)
Tuesday 21 May 2024
Afternoon (Time: 2 1CP2/ Paper
referen
Computer Science
hours)
ce
🞍 🞍


02
PAPER 2: Application of Computational
Thinking
You must have:
a computer workstation with appropriate programming language code editing
software and tools, including an IDE that you are familiar with which shows line
numbers
a ‘STUDENT CODING’ folder containing code and data files
printed and electronic copies of the Program Language Subset (PLS)
document (enclosed).


Instructions

••Save the new or amended code in the ‘COMPLETED CODING’ folder using the
Answer all questions on your

name given in the
• Do not overwrite the original code and data files provided to you.
• You must not use the internet at any time during the
Information

• The total mark for this paper is 75.
•–The marks for each question are shown in
use this as a guide as to how much time to spend on each question.
• The ‘STUDENT CODING’ folder in your user area includes all the code and
data files you need.

Advice
• Read each question carefully before you start to answer it.
• Save your work
• Check your answers and work if you have time at the end.




Turn over


P75441RA
©2024 Pearson Education

, Answer ALL
questions.
Suggested time: 10 minutes
1 A program is written to provide information about the rainbow.

Colours and wavelengths are stored in arrays. For example, the colour Violet
is produced when the wavelength is from 380 to 424

The user enters an index and the colour at that array location is displayed.
The user enters a wavelength and the colour for that wavelength is displayed.


Open file Q01.py


Amend the code to:

• fix the syntax error on original line 5
waveTable = [380, 425, 450, 492, 577, 597", 622]
• fix the NameError on original line 6
found = false
• fix the syntax error on original line 8
wavelength = 0123
• fix the syntax error on original line 15
index = int (input ("Enter an index: ")
• fix the NameError on original line 21
color = rainbow[index]
• fix the ValueError on original line 22
print (int (colour))
• fix the logic error on original line 26
if ((wavelength < 380) and (wavelength > 622)):
• fix the logic error on original line 29
index = 1
• fix the logic error on original line 35
elif (waveTable[index] <= wavelength):
• fix the logic error on original line 37
print (rainbow[index - 2])


Do not change the functionality of the given lines of
code. Do not add any additional functionality.
Save your amended code as Q01FINISHED.py


(Total for Question 1 = 10 marks)


2 P7544

,Suggested time: 15 minutes
2 A program encrypts a message using a Caesar cipher.

The letters of the alphabet are shifted a set number of places. A positive
shift moves the letters to the right. A negative shift moves them to the left.

Blanks, symbols and numbers are not encrypted.

When the end of the alphabet is reached with a positive shift, shifting
continues at the start of the alphabet. When the start of the alphabet is
reached with a negative shift, shifting continues at the end of the alphabet.
For example, a shift of −2 encodes the plaintext letter P to the ciphertext
letter N. A shift of +4 encodes the plaintext letter X to the ciphertext letter
B.

When working correctly, the program produces the encrypted ciphertext for
these plaintext messages and shift inputs.

Plaintext Shif Ciphertext
t
The Rainbow 4 Xli Vemrfsa

Alphabet −5 Vgkcvwzo
Soup Njpk
123 ^&* Bye 9 123 ^&* Khn


Open file Q02.py


Amend the code to make the program work and produce the
correct output. You will need to:

• choose between alternative lines of code. Make a choice by removing the
# at the beginning of the line you choose to execute

• run the program with the data from the table and check it
meets the requirements.


Do not change the functionality of the given lines of
code. Do not add any additional functionality.
Save your amended code as Q02FINISHED.py


(Total for Question 2 = 10 marks)




P7544 3

, Suggested time: 20 minutes
3 A program is required to calculate the total cost of items purchased. Items
are sold by count or by weight.

The user enters the number 1 if the purchase is by count or the number 5 if
the purchase is by weight of items. The user then enters either the count or
the weight in kilograms.

The program checks for invalid input. If the input is valid, the program calculates
and displays the total cost.

Currency formatting with two decimal places and a symbol is not
required. The table shows test results.

Purchas Count Weight
Output
e of in
categor items kilogram
y s
1 3 Total cost is 3.69

1 0 Invalid number of
items
5 4.5 Total cost is 15.525

5 −6.6 Invalid weight

3 Invalid purchase
type

Open file Q03.py

Amend the code to:

• create an integer variable named purchaseType and set it to 0
• complete a line with the correct logical operator and the correct constant

• complete a line with the correct constant

• complete a line to accept a real value for the weight in kilograms

• complete a line to calculate the total cost based on weight

• complete a line to check for a 0 or negative count of items

• complete a line with the correct relational operator

• add a line to display an informative message and the total cost.

Do not add any additional functionality.
Save your amended code as Q03FINISHED.py


4 P7544

Written for

Course

Document information

Uploaded on
October 25, 2024
Number of pages
36
Written in
2024/2025
Type
Exam (elaborations)
Contains
Only questions

Subjects

$17.79
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
margaretmbugua453 Cambridge College
Follow You need to be logged in order to follow users or courses
Sold
35
Member since
2 year
Number of followers
27
Documents
235
Last sold
1 year ago

4.3

7 reviews

5
5
4
1
3
0
2
0
1
1

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions