1/119
Flashcards for the unit computational thinking
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Abstraction
the process of removing unnecessary details and including only the relevant details
Decomposition
Breaking a complex problem into smaller parts
Subprogram
A block of code that has a unique name, does a small action, and can be used over and over again.
How do we call subprograms?
Write its name in brackets
Input
What the program needs to receive ; choose correct data and code
Process
What calculations and transformations are done to the code
Output
What the program should display/return, with appropriate names and data types.
Pseudocode
looks like code but its not for real computer. halfway between english and code
What are the three ways to write algorithms?
Flowcharts, pseudocode, and Python program code.
What is a comment in Python and how is it written?
A comment is text ignored by the program, written after a #
symbol.
What is an identifier in programming?
A name used for variables, procedures, or functions. It starts with a letter and can include letters, digits, and underscores.
What is assignment in Python?
Setting a value to a variable using =
(e.g., x = 5
or volume = width * height * depth
).
Name the four primitive data types.
Integer, Real (Float), Boolean, Character.
What are structured data types?
Types that hold multiple values:
String (sequence of characters)
Array (same data types)
Record (mixed data types)
How do you convert data types in Python?
Using functions like int()
, str()
, float()
, bool()
.
What does input()
do in Python?
It gets data from the keyboard.
What does print()
do in Python?
It displays data on the screen.
What is sequence in programming?
Code is run from top to bottom, one line after another.
What is blocking in Python?
Using indentation to show which lines belong together, like in loops or if statements.
What is selection in Python?
Making a choice using if
, if-else
, or if-elif-else
based on a condition.
What is repetition in Python?
Using a while
loop to repeat code while a condition is true.
What is iteration in Python?
Using a for
loop to repeat code a set number of times.
What is a subprogram?
A smaller part of a program. It can be a procedure or function.
Name some extra concepts from the subset document.
Arithmetic operators, relational operators, Boolean logic, file handling, string manipulation, list methods, random numbers, maths functions, time module, Turtle graphics.
What is a data structure?
A data structure is a special way of organising and storing data.
Name some common data structures.
Arrays, lists, files, records, and tables
What is a string made of?
A string is made of individual characters stored together
What is an array?
An array is a static data structure that stores multiple items of the same data type in one variable
Are arrays static or dynamic?
Arrays are static, meaning their size cannot change once created.
What does "contiguous memory" mean?
It means the data items in the array are stored next to each other in memory.
What is an index in an array?
It is the position of an item in the array, starting from 0.
What is a one-dimensional array?
An array that stores data in a single line (like a list).
What is a two-dimensional array?
An array with rows and columns, like a table.
In an exam, what data type can an array store?
Arrays can only store one data type (e.g., all integers or all strings).
How do you access a two-dimensional array item?
By using two indexes: one for the row and one for the column.
What is a record data structure?
A record stores multiple fields of different data types in one structure.
Can Python use record structures?
No, but other languages like Visual Basic can.
What are the 3 steps to use a record?
1. Define the record, 2. Declare a variable, 3. Assign data to fields.
What is dot notation in a record?
It's how you access a field in a record, like car1.price
.
What is a three-dimensional array?
It's like a cube; you use 3 indexes to access data (height, width, depth).
What does the Arithmetic Logic Unit (ALU) do?
It performs arithmetic operations, logical comparisons, and binary shifts.
What symbol is used for addition in programming?
The plus (+) symbol.
What symbol is used for subtraction in programming?
The minus (-) symbol.
What symbol is used for multiplication in programming?
The asterisk (*) symbol.
What symbol is used for division in programming?
The slash (/) symbol.
What symbol is used for exponentiation (power)?
The double asterisk ()** symbol.
What does modulus do, and what symbol is used?
Modulus finds the remainder after division. It uses the percent (%) symbol.
What does integer division do, and what symbol is used?
It returns the whole number result of division. It uses two slashes (//).
What symbol is used for "equals to" in comparisons?
Double equals (==)
Why do we use double equals (==) and not single equals (=)?
Double equals is for comparison, single equals is for assignment.
What symbol means "not equal to"?
Exclamation mark and equals (!=)
What symbol means "less than"?
Less than (<)
What symbol means "less than or equal to"?
<=
What symbol means "greater than"?
>
What symbol means "greater than or equal to"?
>=
What are the 3 main Boolean operators in programming?
NOT
, AND
, and OR
What does the Boolean operator NOT
do?
t reverses the value.
If something is true
, NOT
makes it false
, and vice versa.
What does the Boolean operator AND
do?
It checks if both conditions are true
.
The result is only true
if both sides are true
.
What does the Boolean operator OR
do?
It checks if at least one condition is true
.
Only one side needs to be true
for the whole thing to be true
.
What is a Boolean expression?
An expression that evaluates to either true
or false
.
Where do you often see Boolean expressions?
In if
statements, while
loops, and do until
loops.
What happens in an if
statement with a Boolean expression?
The code runs only if the expression is true
.
What happens in a while
loop with a Boolean expression?
The loop runs while the expression is true
.
What happens in a do until
loop with a Boolean expression?
The loop runs until the expression becomes true
.
Can Boolean operators be combined?
Yes! You can write things like:if this AND this OR this BUT NOT that
What are the 3 main types of errors in programming?
Syntax errors
Logic errors
Runtime errors
What is a syntax error?
An error that breaks the rules of the programming language (grammar).
It stops the program from running or compiling.
Are syntax errors easy to spot?
Yes. The IDE often shows where the error is and may even suggest a fix.
What is a logic error?
The code runs, but it gives the wrong or unexpected result because of a mistake in how the logic was written.
Are logic errors easy to spot?
No. They are harder to find than syntax errors because the program still runs.
What is a runtime error?
An error that crashes the program while it’s running, even if there are no syntax or logic errors.
Give examples of runtime errors.
Trying to access a file that doesn't exist
Lost connection to a printer or server
If a program asks for user input but doesn't convert the input to an integer, what kind of error is it?
Syntax error
What kind of error is using the wrong comparison operator, like <
instead of >=
?
Logic error — the code runs, but gives the wrong result.
Why are logic errors tricky to find?
Because the code runs normally, but the output is wrong due to a small mistake in the logic.
What is the purpose of the bubble sort algorithm?
To sort a list of items into the correct order (e.g., smallest to largest or A to Z).
How does bubble sort decide if two items need to be swapped?
It compares each item with the one next to it. If they are in the wrong order, they are swapped.
What happens after each full pass through the list?
The largest (or smallest) unsorted item "bubbles" to its correct position.
When does the bubble sort algorithm stop?
When it completes a pass without making any swaps.
Why is bubble sort not used for large data sets?
It is inefficient and slow for large lists because it makes many comparisons and swaps.
Why is bubble sort sometimes used even though it's slow?
Because it is simple to understand and easy to program.
What is a "pass" in bubble sort?
One complete trip through the list, comparing and swapping where needed.
What is the purpose of the "swapped" flag in the algorithm?
To check if any swaps happened during a pass. If no swaps happen, the list is sorted.
In the bubble sort pseudocode, what does N
represent?
The number of items still left to check. It decreases after each pass.
What is the worst-case time complexity of bubble sort?
O(n²), where n is the number of items in the list.
What type of method does merge sort use?
Divide and conquer.
Why is merge sort more efficient than bubble sort?
Because it splits the list and solves smaller problems, combining the results.
What is the first step of merge sort?
The list is repeatedly split in half until each item is on its own.
Is merge sort better for large or small lists?
It works very well for large lists.
What does "merge" mean in merge sort?
To combine two sorted lists into one sorted list.
What is a disadvantage of merge sort?
It takes more memory and is harder to program.
Why might you choose bubble sort over merge sort?
Bubble sort is simpler and easier to understand or program.
In merge sort, how are items compared when merging?
The first item in one list is compared to the first in another; the smallest goes into the new list.
What does "memory footprint" mean in merge sort?
It uses more memory because of all the sublists created during sorting.
How does merge sort compare to bubble sort in terms of speed?
Merge sort is typically much faster than bubble sort.
What is a linear search?
It's a simple algorithm that checks each item in a list one by one until it finds the target.
Does a linear search need the list to be sorted?
No, it works on unsorted data.
Is linear search good for large data sets?
No, it's inefficient for large data sets.
Is linear search easy or hard to code?
Very easy to code.
What’s a real-life example of a linear search?
Looking for a cereal box on a shelf, checking each one in order.