Tick (✓) one box in each row to identify whether the OCR Reference Language code given is an example of selection or iteration.
OCR Reference Language code | Selection | Iteration |
---|---|---|
| ||
| ||
| ||
|
Did this page help you?
Tick (✓) one box in each row to identify whether the OCR Reference Language code given is an example of selection or iteration.
OCR Reference Language code | Selection | Iteration |
---|---|---|
| ||
| ||
| ||
|
How did you do?
Did this page help you?
Jack’s program uses the addition (+) arithmetic operator.
This adds together two numbers.
State the purpose of each of the arithmetic operators in the table
Arithmetic operator | Purpose |
---|---|
* | |
/ |
How did you do?
Did this page help you?
Customers at a hotel can stay between 1 and 5 (inclusive) nights and can choose between a basic room or a premium room.
A typical booking record is shown in the table:
| Amaya |
---|---|
| Taylor-Ling |
| 3 |
| Premium |
| False |
State the most appropriate data type for the following fields:
Nights | |
---|---|
Room |
How did you do?
Give the name of one field that could be stored as a Boolean data type.
How did you do?
Did this page help you?
A program is written to allow a user to enter the radius of a circle as a whole number between 1 and 30, then calculate and output the area of the circle.
Identify two variables used in the program
01 radius = 0
02 area = 0.0
03 radius = input("Enter radius")
04 if radius < 1 OR radius > 30 then
05 print("Sorry, that radius is invalid")
06 else
07 area = 3.142 * (radius ^ 2)
08 print (area)
09 endif
How did you do?
Identify one item in the program that could have been written as a constant.
How did you do?
Give one reason why you have identified this item as a constant.
How did you do?
Tick (✓) one box in each row to identify whether each programming construct has or has not been used in the program in part (a).
Has been used | Has not been used | |
---|---|---|
Sequence | ||
Selection | ||
Iteration |
How did you do?
Did this page help you?
A teacher asks students how long they spend completing homework. Students answer in minutes and hours (for example 2 hours 15 minutes).
The teacher would like to create an algorithm that will display students’ inputs in minutes only.
Identify the input and output required from this algorithm.
Input | |
---|---|
Output |
How did you do?
Did this page help you?
State what is meant by a real data type and give an example of this data type.
How did you do?
State what is meant by an integer data type and give an example of this data type.
How did you do?
Did this page help you?
A programmer declares the following variables.
first = "Computer Science"
second = "is great"
State one difference between a variable and a constant.
How did you do?
Did this page help you?
Write a pseudocode statement to assign the value 7.3
to a variable with the identifier timer
How did you do?
State the most appropriate data type for the variable timer
.
How did you do?
Did this page help you?
OCR High School uses a computer system to store data about students’ conduct.
The system records good conduct as a positive number and poor conduct as a negative number.
A TRUE or FALSE value is also used to record whether or not a letter has been sent home about each incident.
An example of the data held in this system is shown below in Fig. 1:
StudentName | Detail | Points | LetterSent |
---|---|---|---|
Kirstie | Homework forgotten | −2 | FALSE |
Byron | Good effort in class | 1 | TRUE |
Grahame | 100% in a test | 2 | FALSE |
Marian | Bullying | -3 | TRUE |
State the most appropriate data type used to store each of the following items of data.
StudentName | |
---|---|
Points | |
LetterSent |
How did you do?
Did this page help you?
Identify two basic programming constructs that have been used in this algorithm.
01 for k = 1 to 3
02 for p = 1 to 5
03 print (k + p)
04 next p
05 next k
06 m = 7
07 print m * m
1 | |
---|---|
2 |
How did you do?
Did this page help you?
An infinite loop is where a section of a program repeats indefinitely.
For each of the pseudocode algorithms shown below, tick the appropriate box to show whether they will loop infinitely or not.
Pseudocode | Will loop infinitely | Will not loop infinitely |
---|---|---|
| ||
| ||
| ||
|
How did you do?
Did this page help you?
A teacher researches the length of time students spend playing computer games each day.
Tick (✓) one box to identify the data type you would choose to store the data and explain why this is a suitable data type.
Data Type | Tick (✓) one box |
---|---|
String | |
Integer | |
Real | |
Boolean |
Explanation: |
---|
How did you do?
Did this page help you?
DIV
and MOD
are both operators used in computing-related mathematics.
State the value of 13 DIV 4
How did you do?
State the value of 13 MOD 4
How did you do?
Did this page help you?
The symbol ^ is used for exponentiation.
Give the result of a^b
when a = 3
and b = 2
.
How did you do?
Did this page help you?
Each member of staff that works in a restaurant is given a Staff ID. This is calculated using the following algorithm.
01 surname = input("Enter surname")
02 year = input("Enter starting year")
03 staffID = surname + str(year)
04 while staffID.length < 10
05 staffID = staffID + "x"
06 endwhile
07 print("ID " + staffID)
Define the term casting and give the line number where casting has been used in the algorithm.
Definition | |
---|---|
Line number |
How did you do?
Did this page help you?
Identify and correct the errors in the Python program below.
Explain why each correction is necessary.
NAME = "Alice"
PI = 3.14159
name = "Bob"
NAME = "Charlie"
radius = 10
area = PI * radius ^ 2
print("The area of the circle is", area)
How did you do?
Did this page help you?
Modify the Python code to include a selection construct that only adds even numbers to the total.
total = 0
for i in range(5):
num = int(input("Enter a number: "))
total = total + num
print("Total is:", total)
How did you do?
Did this page help you?
Identify the output of each print
statement in the following Python program:
a = True
b = False
print(a and b)
print(a or b)
print(not a)
Statement | Output |
---|---|
| |
| |
|
How did you do?
Modify the code in part(a) to include a conditional that prints:
"Both are True" if both a
and b
are true
AND
"One is True" if either a
or b
is true but not both
How did you do?
Did this page help you?