Algorithms and Khwarizmi | |
|---|---|
| | The word “algorithm” comes from the name of the 9th-century Persian mathematician al-Khwarizmi, who lived in the region of Khwarazm (now part of Uzbekistan). His work on arithmetic and algebra was foundational in medieval mathematics, and his name was Latinized as “Algoritmi,” eventually giving rise to the modern term “algorithm.” |
An algorithm is a set of steps that accomplishes a task, such as the steps involved in synthesizing caffeine. Each function in a program, as well as the program itself, is an algorithm that is written in a programming language like Python. Writing a program directly in Python, without careful planning, can waste hours, days, or even weeks of effort. Instead, programmers often write algorithms in a combination of English and mathematics and then translate them into Python.
The most effective way
to design algorithms is
to use top-down design
In this chapter, you’ll learn an algorithm-writing technique called top-down design. You start by describing your solution in English and then mark the phrases that correspond directly to Python statements. Those that don’t correspond are then rewritten in more detail in English until everything in your description can be written in Python.