1/53
GCSE praactise paper 2
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What does this symbol mean on a flowchart?
The arrow symbol connects the different boxes and shows the direction they should follow.
What does this symbol mean on a flowchart?
This symbol is the decision flowchart symbol. This is where a decision is made in the code and it splits into multiple branches. E.g an if function.
What does this symbol mean on a flowchart?
This is the subprogram symbol. A subprogram is where there is a smaller out of the way section of code in a whole program designed to do a specific task for a large program. Subprograms can also be repeatable multiple times. The two types are procedures that don’t return a value( but can still output messages) and functions that return something
What does this symbol mean on a flowchart?
This is the Input/output symbol. Any inputs from the user e.g “input(what is your name)” or outputs from the program e.g”print(hello)” go in this box.
What does this symbol mean on a flowchart?
This is the processes symbol. This is any instructions, processes or calculations the computer does.
What does this symbol mean on a flowchart?
This is the start/stop
What is computational thinking?
"Computational thinking is a way of solving problems like a computer scientist. It includes:
Decomposition: Breaking big problems into smaller parts.
Abstraction: Focusing on important details and ignoring irrelevant ones.
Pattern recognition: Spotting similarities to make solving easier.
Algorithms: Creating step-by-step instructions to solve the problem.
For example, if you’re planning a trip, you’d break it into steps like transport, accommodation, and activities (decomposition), ignore the unimportant details (abstraction), and plan out a schedule (algorithm)."
What is decomposition?
Decomposition means breaking a big problem into smaller chunks so it’s easier to solve. For example, creating a game might involve smaller tasks like designing characters, writing rules, and coding movement. This makes the task more manageable and helps different people work on it at the same time.
What is abstraction?
Abstraction is about simplifying problems by focusing on the important parts and ignoring the rest. For example, a map ignores details like trees but shows roads and landmarks because they’re what’s important for navigation.
What is an algorithm?
An algorithm is a set of step-by-step instructions to solve a problem. For example, making a sandwich has an algorithm:
Get the bread.
Spread butter on one slice.
Add your filling.
Put the slices together.
Computers use algorithms for everything, like sorting data, searching for information, or making calculations.
What is pseudocode?
Pseudocode is a way to plan a program before writing the actual code. It uses plain English and programming-like terms to describe what the program will do.
For example:
Copy code
IF the user enters their name
PRINT 'Hello, [name]'
ELSE
PRINT 'Please enter your name'
It’s not real code, but it helps you think about how the program will work.
What is a flowchart?
A flowchart is a diagram that shows the steps in an algorithm visually. It uses shapes to represent different actions
What is the difference between linear search and binary search?
Both are ways to find something in a list, but they work differently:
Linear search: Goes through the list item by item until it finds the one you’re looking for. It works for any list, even if it’s not sorted, but it’s slow for big lists.
Binary search: Only works on sorted lists. It starts in the middle, checks if the target is higher or lower, and keeps dividing the list until it finds the item. It’s much faster than linear search.
What is bubble sort? How is it different from merge sort?
Both are ways to sort a list of numbers or data:
Bubble sort: Repeatedly compares two numbers next to each other and swaps them if they’re in the wrong order. It’s simple but very slow for large lists.
Example: To sort [5, 3, 1], compare 5 and 3 (swap), then 5 and 1 (swap). Repeat until sorted.
Merge sort: Splits the list into smaller and smaller parts, sorts them, and then merges them back together in the correct order. It’s faster but more complex than bubble sort.
What is iteration?
Iteration is when a program repeats a block of code. This is done using loops, like:
For loop: Repeats a specific number of times.
While loop: Repeats as long as a condition is true.
For example, if you wanted to print numbers 1 to 5:
for i in range(1, 6):
print(i)
This will print 1, 2, 3, 4, 5.
What is selection in programming?
Selection is when a program makes a decision and chooses between different actions based on a condition. This is done with if
statements.
Example:
if temperature > 30:
print('It’s hot')
else:
print('It’s cold')
The program selects what to do depending on the condition.
What are trace tables used for?
A trace table helps you check if an algorithm works correctly. You write down all the variables and update their values step by step as the algorithm runs.
For example, if an algorithm adds numbers, the table would show how the total changes after each step.
What is a subprogram?
A subprogram is a small piece of code inside a bigger program. It performs a specific task. There are two types:
Procedure: Does something but doesn’t return a value.
Function: Does something and returns a value.
For example, you might have a function to calculate a discount in a shopping app:
def calculate_discount(price):
return price * 0.9
This function takes the price and returns the discounted amount.
What is an array? How is it used?
An array is a data structure that stores a collection of values, all of the same type, in one place. For example, you can store a list of student names or scores.
Example in Python:
scores = [85, 90, 78]
print(scores[0])
# Prints 85
Arrays are useful for storing multiple values without creating lots of variables.
What is the difference between high-level and low-level languages?
High-level languages like Python or Java are easy for humans to read and write. They’re translated into machine code so the computer can understand them.
Low-level languages, like assembly code, are closer to machine code and harder to read but give more control over the hardware.
What are the advantages of using subprograms in coding?
Subprograms, like functions and procedures, make code easier to write, understand, and debug because:
They break the program into smaller, reusable parts.
You can call them multiple times instead of rewriting the same code.
They make big projects manageable and organised.
For example, a function for calculating tax can be reused every time you need it.
What is defensive programming? Why is it important?
Defensive programming means writing code that prevents errors or handles unexpected inputs. It ensures the program runs smoothly by:
Validating user input (e.g., checking if a number is within range).
Using error messages to inform the user.
Adding comments to make the code understandable.
Example: A program asks for a number between 1 and 10. Defensive programming checks the input and gives an error if it’s out of range.
What is the difference between testing and debugging?
Testing: Checking if a program works as expected. For example, running your code with different inputs to see if it breaks.
Debugging: Fixing errors found during testing. For example, correcting a syntax error or a logical mistake in your code.
They work together to make your program error-free.
What are the different types of test data?
When testing a program, you use these types of data:
Normal data: Data the program is expected to handle (e.g., 5 in a range of 1-10).
Boundary data: Values on the edges of valid inputs (e.g., 1 and 10).
Erroneous data: Invalid data to check how the program handles errors (e.g., letters when numbers are required).
What is a syntax error? How is it different from a logic error?
Syntax error: Happens when your code breaks programming rules, like missing a colon in Python. The program won’t run.
Logic error: Happens when your code runs but doesn’t give the correct result because of a mistake in your algorithm.
Example:
# Syntax Error:
print('Hello'
# Missing closing parenthesis
# Logic Error:
area = length + width
# Should be length * width
What is the difference between a dry run and a trace table?
Dry run: Going through the code manually to check how it works without running it.
Trace table: Recording the values of variables line by line to check the program’s flow.
For example, if your algorithm calculates the total of a list, you could use a trace table to track the total after each addition.
What is a binary search tree?
A binary search tree is a way to organise data for fast searching. Each node has:
A value.
A left branch (for smaller values).
A right branch (for larger values).
For example, if 10 is the root, numbers smaller than 10 go to the left, and bigger ones go to the right.
What is validation, and how is it used?
Validation is checking if the input data is sensible and meets the program’s requirements. Examples include:
Range check: Ensuring a number is within a range (e.g., 1–100).
Type check: Ensuring the input is the right type (e.g., numbers, not letters).
Length check: Ensuring the input has the correct number of characters (e.g., a 4-digit PIN)."
What is a logic gate? Name three types.
Logic gates are basic components of computer circuits that make decisions using Boolean logic:
AND Gate: True if both inputs are true.
OR Gate: True if at least one input is true.
NOT Gate: Reverses the input (true becomes false).
These gates are used in everything from calculators to CPUs.
What are the benefits of using an IDE for programming?
An Integrated Development Environment (IDE) makes coding easier by providing tools like:
Syntax highlighting: Colour-coding to make code readable.
Debugging tools: Help find and fix errors.
Auto-completion: Suggests code as you type.
Examples of IDEs include Visual Studio Code and PyCharm.
How does bubble sort work?
Bubble sort repeatedly compares two adjacent numbers and swaps them if they’re in the wrong order. It keeps going until the list is sorted.
For example, sorting [5, 3, 1]:
Compare 5 and 3 (swap to [3, 5, 1]).
Compare 5 and 1 (swap to [3, 1, 5]).
Repeat until sorted to [1, 3, 5].
Bubble sort is simple but slow for large lists.
simple algo
efficient way to check if its already in order
doesn’t use much memory as it alters the original array.
inefficient with large lists
What are the steps of a merge sort?
Merge sort is a divide-and-conquer algorithm:
Divide the list into halves repeatedly until each part has one item.
Merge the parts back together in the correct order.
For example, sorting [4, 2, 7, 1]:
Divide into [4, 2] and [7, 1].
Divide again: [4], [2], [7], [1].
Merge: [2, 4] and [1, 7].
Merge: [1, 2, 4, 7].( merge the two arrays like expanding brackets. e.g. 2 compared to 1 means 1 is sorted, then 2 is compared with 7 and 2 is smaller than 7 so 2 is sorted ext.)
Merge sort is faster than bubble sort for large lists.
very consistent running time
slower for smaller lists
even if its already sorted it goes through the splitting and merging process
uses more memory than other algorithms.
What is MOD?
Modulus is the whole number left over when you do a division. e.g. 14 mod 4 If you went across number line you could visualise it like this:
Step 1: Start at 0.
Step 2: Move 4 steps forward (0 + 4 = 4).
Step 3: Move another 4 steps forward (4 + 4 = 8).
Step 4: Move another 4 steps forward (8 + 4 = 12).
Step 5: Move 2 more steps forward (12 + 2 = 14).
you move two steps forward at the end so modulus is 2.
REMAINDER
What is DIV?
TRUNCATION
Quotient is the whole number when you do a division that isn’t an integer. e.g. 3 DIV 2 = 1. because 1 is left out when you get rid of the remainder. Its written as // in python.
What is the difference between Invalid and Erroneous data
Invalid data is the correct data type isn’t in the boundary needed for it to be correct. e.g. 5 characters in a 4 digit code.
Erroneous data is where the data type is wrong and it should give an error in the program. e.g hfyw8 in a 4 digit numerical code.
What is the structure for select in SQL
SELECT * FROM Customers WHERE age >30
SELECT = statement to get data
* = a placeholder for the whole row of data to gather in to data
FROM = choosing a data column / table to find the data from
Customers = a row / column with data
WHERE = Choosing a point where to filter the data out( not necessary unless you want to filter)
age > 30 = filters the data to people who’s age is more than 30
How to do an insertion sort and how to define it? What positives and negatives does it have?
Similar to bubble sort where it logically goes through and sorts the data from the first item in the list.
Good for short lists,
can easily be coded,
doesn’t require additional memory as the sorting is done on the original list
very quick
doesnt cope with large lists.
definition: A simple sorting algorithm that in turn inserts the items into the right place using the first item in the list as a starting point.
What is casting?
Manually converting through data types.
e.g. int(“1”)
str(True)
bool(1) converts it to True
CHR(98) converts it to the character 98 in Ascii.
casting a float to an int truncates it.
How do different types of loops work?
Condition controlled:
DO UNTIL = controlled by a condition at the end of the loop and goes until the condition is true. can result in an infinite loop
WHILE = controlled by a condition at the start of a loop
count controlled:
loop a fixed number of times.
What’s a 2 d array and how to visualise it?
an array with arrays inside of it. Represented in the picture next to it.
List the three main logic gates and their purpose.
AND OR NOT
These gates perform calculations and are created using transistors. EVERY logic gate can be made up of these three.
What is a truth table?
The output of logic gates.
How does an AND gate work?
Only and output if A AND B are 1.
Written as : A⋀B
How does an OR gate work?
Only and output if A OR B are 1.
Written as : A ⋁ B
How does a NOT gate work?
only one input (A)
Inverts the input( a = 0 a or y = 1) (a = 1 a or y = 0)
Written as : NOT A
How to work out number of rows for a truth table?
Number of Rows=2^(number of inputs)
What’s the whole process for constructing a truth table?
calculate number of rows 2^n(num of inputs) e.g. Q= (A OR B) AND (NOT C) would be 3 inputs. 2³ = 8. 8 rows
fill in the table columns based on question. e.g. the columns would be ( A, B, C, A OR B, NOT C, Q)
fill out the logic gates
A | B | C | A OR B | NOT C | Q = (A OR B) AND (NOT C) |
---|---|---|---|---|---|
0 | 0 | 0 | 0 | 1 | 0 |
0 | 0 | 1 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | 1 | 1 |
0 | 1 | 1 | 1 | 0 | 0 |
1 | 0 | 0 | 1 | 1 | 1 |
1 | 0 | 1 | 1 | 0 | 0 |
1 | 1 | 0 | 1 | 1 | 1 |
1 | 1 | 1 | 1 | 0 | 0 |
What is iterative testing?
Testing the code as its created.
You can alter the code based on the feedback received.
What is final testing or terminal testing?
Testing carried out at the end of the program.
Its supposed to be a final check to make sure the program runs properly.
What is a runtime error?
an error where the code crashes unexpectedly with no particular reason.
This could be running out of memory or dividing by 0.
How do refine your code?
Making programs not accept invalid/ erroneous values.
Using loops to run until valid data is entered.
What are the advantages and disadvantages of pseudocode
ADV:
easily converted to actual programming language
easy to understand even for non programmers
easy to incorporate changes
does not matter if errors found on syntax
DIS:
hard to see how the program flows. e.g. how you can take the different paths
time consuming
What are the advantages and disadvantages of flowcharts?
ADV:
easy to see how a program flows
easy to understand
DIS:
these become large and hard to follow in large programs
any changes to the design means a lot has to be changed
Explain a structure diagram and its advantages.
They show the smaller tasks of a larger problem. They decompose the problems into manageable modules. subprograms can be used to carry out each individual tasks.
Writing code is easier as it only carries out very simple tasks
lots of programmers can work on each different module independently
easier to test structured programs as each module can be tested individually
you can reuse subprograms and modules written.