CodeBlanks Logo Icon CodeBlanks

Summary - Algorithm concept

Tie definition, properties and pseudocode together with a mini task.

Summary - Algorithm concept

In this group you learned what an algorithm is, its five core properties and how to express it in pseudocode. An algorithm has finite, definite and effective steps.

Pseudocode is a human-friendly way to write algorithms using if, for, return.

Practice Subtract two numbers

Write subtract(a, b). Return a - b and print 7 with print(subtract(10, 3)).

Starter code

solution.py
def subtract(a, b):
    # Subtract two numbers

Sample solution

solution.py
def subtract(a, b):
    # Subtract two numbers
    return a - b
print(subtract(10, 3))

Expected output

7

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Summary - Algorithm concept: match the terms

Term Meaning
Algorithm Step sequence
Finiteness Ends
Pseudocode Human reads
Output Result

2 Algorithm definition

Question
An algorithm is a ____ sequence of steps.
Answer
An algorithm is a finite sequence of steps.

Explanation: finite is right.

3 Which is required for an algorithm?

  • Infinite loop
  • Randomness
  • Ambiguity
  • Finiteness Correct answer

Explanation: Finiteness is required.

All lessons in Beginner