1/82
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
In programming, which construct involves executing instructions one after the other in the order they are written?
Sequence
Which programming construct uses $if$ statements or $switch/case$ to choose a path based on a condition?
Selection
The process of repeating a block of code using loops is known as _.
Iteration
What is the specific name for a loop that repeats a set number of times, such as a $for$ loop?
Count-controlled iteration
What type of iteration repeats until a specific condition is met, such as a $while$ or $do\ until$ loop?
Condition-controlled iteration
Arithmetic Operator: What is the purpose of the $+$ operator?
Addition
Arithmetic Operator: What is the purpose of the $/$ operator?
Division
Arithmetic Operator: What is the purpose of the $MOD$ (Modulo) operator?
It returns the remainder after a division.
Arithmetic Operator: What is the purpose of the $DIV$ operator?
It returns the quotient (the whole number of times a number goes into another).
Evaluate the expression: $7\ DIV\ 2$.
$3$
Evaluate the expression: $7\ MOD\ 2$.
$1$
Arithmetic Operator: What does the symbol $\text{^}$ represent in OCR Exam Reference Language?
Exponentiation (to the power of).
Comparison Operator: What does the symbol $==$ represent?
Equal to
Comparison Operator: What does the symbol $!=$ represent?
Not equal to
Comparison Operator: What does the symbol $<=$ represent?
Less than or equal to
Comparison Operator: What does the symbol $>=$ represent?
Greater than or equal to
Boolean Operator: Which operator returns $True$ only if both conditions being compared are true?
AND
Boolean Operator: Which operator returns $True$ if at least one of the conditions being compared is true?
OR
Boolean Operator: Which operator reverses the logical state of its operand?
NOT
Data Type: What is the most appropriate data type for a whole number like $7$ or $-12$?
Integer
Data Type: What is the most appropriate data type for numbers with a decimal point like $3.14$?
Real (or Float)
Data Type: What is the most appropriate data type for a variable that can only be $True$ or $False$?
Boolean
Data Type: What is the most appropriate data type for a single letter, number, or symbol?
Character
Data Type: What is the name for a collection of characters stored as a single unit?
String
In programming, the process of converting one data type to another is called _.
Casting
What would be the result of the casting operation $int("5")$?
The string "5" is converted into the integer $5$.
String Manipulation: What does the $.length$ function return?
The number of characters in a string.
String Manipulation: What is the purpose of the $.substring(start, length)$ method?
It extracts a specific part of a string based on a starting position and a defined length.
String Manipulation: Which methods are used to change the case of a string to all capitals or all small letters?
$.upper$ and $.lower$
String Manipulation: What does the term 'concatenation' mean?
Joining two or more strings together to form a new string.
File Handling: What is the first step required to link a program to an external file?
Using the $open()$ command.
File Handling: Which command is used to retrieve a single line of data from an opened file?
$.readLine()$
File Handling: Why is it essential to use the $.close()$ command after finishing with a file?
To disconnect the file and prevent data loss.
File Handling: Which command is used to save a new line of data into an external file?
$.writeLine()$
Data Structures: What is a 1D array?
A list of items that are all of the same data type.
Data Structures: How is data typically structured and accessed in a 2D array?
As a table or grid using two indices, typically $[row, column]$.
How would you access the item in the second row and first column of a 2D array named $board$ (using 0-indexing)?
$board[1, 0]$
SQL: Which keyword is used to specify which fields (columns) should be displayed in a database search?
SELECT
SQL: Which keyword is used to specify the table where the database search should look?
FROM
SQL: Which keyword is used to provide criteria to filter a database search?
WHERE
What is the primary difference between a procedure and a function?
A function returns a value to the main program, whereas a procedure performs a task without returning a value.
Variables that are declared inside a sub-program and only exist within that sub-program are called _.
Local variables
What is a 'global variable'?
A variable that can be accessed and updated from anywhere within the program.
Why is the use of local variables considered memory efficient?
They only exist and take up memory while the sub-program is running.
Programming Techniques: What is the purpose of using constants instead of variables?
To store values that do not change during the execution of a program (e.g., $PI$).
How do you define a constant in OCR Exam Reference Language?
Using the $const$ keyword (e.g., $const\ vat = 0.2$).
Which command in OCR Exam Reference Language would you use to generate a whole number between $1$ and $6$?
$random(1, 6)$
In OCR Exam Reference Language, how is a comment denoted?
Using double forward slashes ($//$).
What is the purpose of the $global$ keyword in code?
To declare that a variable is accessible throughout the entire program.
In a $for$ loop, what keyword is used to determine the increment value if it is not $1$?
$step$ (e.g., $for\ i = 2\ to\ 10\ step\ 2$).
What is the difference between a $while$ loop and a $do\ until$ loop regarding when the condition is checked?
A $while$ loop checks the condition before the code runs; a $do\ until$ loop runs the code at least once before checking.
How do you mark the end of an $if$ statement in OCR Exam Reference Language?
$endif$
In a $switch$ statement, what keyword identifies the code to run if none of the specific $case$ conditions are met?
$default:$
String Handling: If $subject = "ComputerScience"$, what is the result of $subject.substring(3, 5)$?
"puter" (starting at index 3, taking 5 characters).
String Handling: What does $subject.left(4)$ return if $subject = "ComputerScience"$?
"Comp"
String Handling: What does $subject.right(3)$ return if $subject = "ComputerScience"$?
"nce"
What is the 0-indexed result of $ASC('A')$?
It returns the numerical ASCII value for the character 'A' (which is $65$).
What does the function $CHR(97)$ return?
The character 'a' (the character associated with the ASCII value 97).
How do you check for the end of a file in a loop using OCR Reference Language?
By using the $.endOfFile()$ function (e.g., $while\ NOT\ myFile.endOfFile()$).
How do you create a new empty text file named "test.txt" in code?
$newFile("test.txt")$
Arrays: How would you declare a 1D array named $colours$ with $5$ elements?
$array\ colours[5]$
Arrays: How would you declare a 2D array named $gameboard$ with $8$ rows and $8$ columns?
$array\ gameboard[8, 8]$
SQL: Write a simple SQL query to find all data from a table named $Cars$ where the $Colour$ is 'Red'.
$SELECT\ *\ FROM\ Cars\ WHERE\ Colour = 'Red'$
How do you define the start and end of a function in OCR Exam Reference Language?
$function\ name()$ and $endfunction$
How do you define the start and end of a procedure in OCR Exam Reference Language?
$procedure\ name()$ and $endprocedure$
When calling a function named $calculate(x)$, how should you handle the value it provides?
Store it in a variable (e.g., $result = calculate(x)$) or use it directly in a statement (e.g., $print(calculate(x))$).
What is the result of $bool("True")$ in casting?
The Boolean value $True$.
What is the result of $float("4.52")$ in casting?
The Real/Float number $4.52$.
In a $for$ loop, what keyword signifies the final value of the counter?
$to$ (e.g., $for\ i = 0\ to\ 9$).
Evaluate the comparison: $5\ !=\ 5$.
$False$
Evaluate the comparison: $10\ >=\ 10$.
$True$
What is the output of $print("Hello" + "World")$?
"HelloWorld"
Data Types: What data type would be best to store the number of students in a class?
Integer
Data Types: What data type would be best to store the price of an item?
Real (Float)
Data Types: What data type would be best to store whether a user has a discount card?
Boolean
Data Types: What data type would be best to store a postcode like "SW1A 1AA"?
String
In code, $x = input("Prompt")$. What data type is the input usually received as by default?
String
How do you obtain a random real number between $-1.0$ and $10.0$?
$random(-1.0, 10.0)$
In a $switch$ statement, what follows the keyword $case$?
A specific value to compare against the switch variable and a colon ($:$).
Why is indentation used in programming constructs like $if$ and $while$?
To clearly show the structure and which block of code belongs to the construct.
Evaluate the logic: $(5 > 3)\ AND\ (2 > 4)$.
$False$ (because the second part is false).
Evaluate the logic: $(5 > 3)\ OR\ (2 > 4)$.
$True$ (because the first part is true).
What is the result of $NOT(True)$?
$False$