Computer science

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/119

flashcard set

Earn XP

Description and Tags

Flashcards for the unit computational thinking

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

120 Terms

1
New cards

Abstraction

the process of removing unnecessary details and including only the relevant details

2
New cards

Decomposition

Breaking a complex problem into smaller parts

3
New cards

Subprogram

A block of code that has a unique name, does a small action, and can be used over and over again.

4
New cards

How do we call subprograms?

Write its name in brackets

5
New cards

Input

What the program needs to receive ; choose correct data and code

6
New cards

Process

What calculations and transformations are done to the code

7
New cards

Output

What the program should display/return, with appropriate names and data types.

8
New cards

Pseudocode

looks like code but its not for real computer. halfway between english and code

9
New cards

What are the three ways to write algorithms?

Flowcharts, pseudocode, and Python program code.

10
New cards

What is a comment in Python and how is it written?

A comment is text ignored by the program, written after a # symbol.

11
New cards

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.

12
New cards

What is assignment in Python?

Setting a value to a variable using = (e.g., x = 5 or volume = width * height * depth).

13
New cards

Name the four primitive data types.

Integer, Real (Float), Boolean, Character.

14
New cards

What are structured data types?

Types that hold multiple values:

  • String (sequence of characters)

  • Array (same data types)

  • Record (mixed data types)

15
New cards

How do you convert data types in Python?

Using functions like int(), str(), float(), bool().

16
New cards

What does input() do in Python?

It gets data from the keyboard.

17
New cards

What does print() do in Python?

It displays data on the screen.

18
New cards

What is sequence in programming?

Code is run from top to bottom, one line after another.

19
New cards

What is blocking in Python?

Using indentation to show which lines belong together, like in loops or if statements.

20
New cards

What is selection in Python?

Making a choice using if, if-else, or if-elif-else based on a condition.

21
New cards

What is repetition in Python?

Using a while loop to repeat code while a condition is true.

22
New cards

What is iteration in Python?

Using a for loop to repeat code a set number of times.

23
New cards

What is a subprogram?

A smaller part of a program. It can be a procedure or function.

24
New cards

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.

25
New cards

What is a data structure?

A data structure is a special way of organising and storing data.

26
New cards

Name some common data structures.

Arrays, lists, files, records, and tables

27
New cards

What is a string made of?

A string is made of individual characters stored together

28
New cards

What is an array?

An array is a static data structure that stores multiple items of the same data type in one variable

29
New cards

Are arrays static or dynamic?

Arrays are static, meaning their size cannot change once created.

30
New cards

What does "contiguous memory" mean?

It means the data items in the array are stored next to each other in memory.

31
New cards

What is an index in an array?

It is the position of an item in the array, starting from 0.

32
New cards

What is a one-dimensional array?

An array that stores data in a single line (like a list).

33
New cards

What is a two-dimensional array?

An array with rows and columns, like a table.

34
New cards

In an exam, what data type can an array store?

Arrays can only store one data type (e.g., all integers or all strings).

35
New cards

How do you access a two-dimensional array item?

By using two indexes: one for the row and one for the column.

36
New cards

What is a record data structure?

A record stores multiple fields of different data types in one structure.

37
New cards

Can Python use record structures?

No, but other languages like Visual Basic can.

38
New cards

What are the 3 steps to use a record?

1. Define the record, 2. Declare a variable, 3. Assign data to fields.

39
New cards

What is dot notation in a record?

It's how you access a field in a record, like car1.price.

40
New cards

What is a three-dimensional array?

It's like a cube; you use 3 indexes to access data (height, width, depth).

41
New cards

What does the Arithmetic Logic Unit (ALU) do?

It performs arithmetic operations, logical comparisons, and binary shifts.

42
New cards

What symbol is used for addition in programming?

The plus (+) symbol.

43
New cards

What symbol is used for subtraction in programming?

The minus (-) symbol.

44
New cards

What symbol is used for multiplication in programming?

The asterisk (*) symbol.

45
New cards

What symbol is used for division in programming?

The slash (/) symbol.

46
New cards

What symbol is used for exponentiation (power)?

The double asterisk ()** symbol.

47
New cards

What does modulus do, and what symbol is used?

Modulus finds the remainder after division. It uses the percent (%) symbol.

48
New cards

What does integer division do, and what symbol is used?

It returns the whole number result of division. It uses two slashes (//).

49
New cards

What symbol is used for "equals to" in comparisons?

Double equals (==)

50
New cards

Why do we use double equals (==) and not single equals (=)?

Double equals is for comparison, single equals is for assignment.

51
New cards

What symbol means "not equal to"?

Exclamation mark and equals (!=)

52
New cards

What symbol means "less than"?

Less than (<)

53
New cards

What symbol means "less than or equal to"?

<=

54
New cards

What symbol means "greater than"?

>

55
New cards

What symbol means "greater than or equal to"?

>=

56
New cards

What are the 3 main Boolean operators in programming?

NOT, AND, and OR

57
New cards

What does the Boolean operator NOT do?

t reverses the value.
If something is true, NOT makes it false, and vice versa.

58
New cards

What does the Boolean operator AND do?

It checks if both conditions are true.
The result is only true if both sides are true.

59
New cards

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.

60
New cards

What is a Boolean expression?

An expression that evaluates to either true or false.

61
New cards

Where do you often see Boolean expressions?

In if statements, while loops, and do until loops.

62
New cards

What happens in an if statement with a Boolean expression?

The code runs only if the expression is true.

63
New cards

What happens in a while loop with a Boolean expression?

The loop runs while the expression is true.

64
New cards

What happens in a do until loop with a Boolean expression?

The loop runs until the expression becomes true.

65
New cards

Can Boolean operators be combined?

Yes! You can write things like:
if this AND this OR this BUT NOT that

66
New cards

What are the 3 main types of errors in programming?

  • Syntax errors

  • Logic errors

  • Runtime errors

67
New cards

What is a syntax error?

An error that breaks the rules of the programming language (grammar).
It stops the program from running or compiling.

68
New cards

Are syntax errors easy to spot?

Yes. The IDE often shows where the error is and may even suggest a fix.

69
New cards

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.

70
New cards

Are logic errors easy to spot?

No. They are harder to find than syntax errors because the program still runs.

71
New cards

What is a runtime error?

An error that crashes the program while it’s running, even if there are no syntax or logic errors.

72
New cards

Give examples of runtime errors.

  • Trying to access a file that doesn't exist

  • Lost connection to a printer or server

73
New cards

If a program asks for user input but doesn't convert the input to an integer, what kind of error is it?

Syntax error

74
New cards

What kind of error is using the wrong comparison operator, like < instead of >=?

Logic error — the code runs, but gives the wrong result.

75
New cards

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.

76
New cards

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).

77
New cards

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.

78
New cards

What happens after each full pass through the list?

The largest (or smallest) unsorted item "bubbles" to its correct position.

79
New cards

When does the bubble sort algorithm stop?

When it completes a pass without making any swaps.

80
New cards

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.

81
New cards

Why is bubble sort sometimes used even though it's slow?

Because it is simple to understand and easy to program.

82
New cards

What is a "pass" in bubble sort?

One complete trip through the list, comparing and swapping where needed.

83
New cards

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.

84
New cards

In the bubble sort pseudocode, what does N represent?

The number of items still left to check. It decreases after each pass.

85
New cards

What is the worst-case time complexity of bubble sort?

O(n²), where n is the number of items in the list.

86
New cards

What type of method does merge sort use?

Divide and conquer.

87
New cards

Why is merge sort more efficient than bubble sort?

Because it splits the list and solves smaller problems, combining the results.

88
New cards

What is the first step of merge sort?

The list is repeatedly split in half until each item is on its own.

89
New cards

Is merge sort better for large or small lists?

It works very well for large lists.

90
New cards

What does "merge" mean in merge sort?

To combine two sorted lists into one sorted list.

91
New cards

What is a disadvantage of merge sort?

It takes more memory and is harder to program.

92
New cards

Why might you choose bubble sort over merge sort?

Bubble sort is simpler and easier to understand or program.

93
New cards

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.

94
New cards

What does "memory footprint" mean in merge sort?

It uses more memory because of all the sublists created during sorting.

95
New cards

How does merge sort compare to bubble sort in terms of speed?

Merge sort is typically much faster than bubble sort.

96
New cards

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.

97
New cards

Does a linear search need the list to be sorted?

No, it works on unsorted data.

98
New cards

Is linear search good for large data sets?

No, it's inefficient for large data sets.

99
New cards

Is linear search easy or hard to code?

Very easy to code.

100
New cards

What’s a real-life example of a linear search?

Looking for a cereal box on a shelf, checking each one in order.