Topic 1: Computational thinking Flashcards
Decomposition
breaking down problems and solutions into smaller parts
Abstraction
the process of removing or hiding unnecessary details (so you can focus on the important poins)
Algorithms
a step-by-step procedure for solving a problem or carrying out a task.
Reason for decomposing problems
to reduce the size of the problem
Subprogram
block of code that performs a specific task
Pre-existing subprograms in python
- print()
- len()
- random.randint()
- math.floor()
Subprograms are useful to:
- break down a complex program into less complicated parts
- make program logic clearer
- make it easier to maintain code
- code can be used as many times as needed, avoiding repetition
- be stored in libraries and reuse them in other programs
- enable a team of programmers to work together at the same time
2 ways subprograms speeds up program development
1) the programmer can use pre-existing subprograms so that they can use them to perform common tasks
2) a group of programmers can work in different subprograms because different subprograms can be allocated to different programmers.
Algorithms : flowcharts
Be able to draw flowcharts
Algorithms: selection
used to choose between two or more options
Selection in flowcharts
Diamond symbol; has 2 output arrows, one for yes and the other for no.
Selection in python
If… elif… else… statement
Algorithms : repetition
the process of repeating a set of instructions until there is a desired outcome
2 types of repetition
Condition-controlled repetition
Count-controlled repetition
Condition-controlled repetition
when the number of times a loop is executed is not known before the loop is started
Count-controlled repetition
when the number of times a loop is executed is known before the loop is started
Condition controlled in python
while statement
Count- controlled in python
for…in range() statement
Reason why loops do not need dedicated symbol in flowcharts
In a selection symbol (rhombus), you can have an arrow pointing at the begining of the choice, therefore that creates autmatically a loop
Reason why loops do not need dedicated symbol in flowcharts
In a selection symbol (Diamond), you can have an arrow pointing at the begining of the choice, therefore that creates autmatically a loop
Algorithms: iteration
Repeating a set of instructions for every item in a data list.
2 features in a flowchart that indicate iteration is used
- A data list
- A backward pointing arrow to a selection symbol
Arrays
data structure that can store multiple elements from the SAME DATA TYPE
2D arrays
[[…],[…],[…]]