10
Lesson 10 of 20 ยท Algorithms
Algorithms โ Part 18
Searching, sorting, efficiency. This is part 18 of 20.
What you'll learn
You will learn that an algorithm is a reusable set of steps that solves a problem for any input.
Steps
- 1An algorithm is a set of clear steps to solve a problem. Here the problem is: double a number. The steps: take n, multiply by 2, show result.
- 2If n is 4, then result = 4 * 2 = 8. The output would be 'Start: 4' then 'Double: 8'.
- 3The beauty of an algorithm: change n to 6, and the same steps give 'Double: 12'. Same recipe, different ingredients!
- 4Algorithms are everywhere: a recipe is an algorithm for cooking, turn-by-turn directions are an algorithm for driving. Code is algorithms for computers!
Key Terms
- Algorithm
- A clear set of steps that solve a problem. Same steps work for different inputs.
- Input
- The data you give to the program (e.g. the number n).
- Result
- What the program produces after following the steps.
Python 3
Output
Loading Python... This may take a few seconds.
Your code runs only in your browser. No code is sent to any server. Stay safe and have fun learning!
๐จ๏ธView in Shop
Checkout complete lesson on Algorithms for 7th Grade
Get the full Algorithms track as a printable PDF โ all lessons, worksheets, and answer keys.
