Introducing Python for Algorithm Programming
77
Creating and Using Functions
Every step in an algorithm normally requires a single line of Python code — an
English-like instruction that tells the computer how to move the problem solution
one step closer to completion. You combine these lines of code to achieve a desired
result. Sometimes you need to repeat the instructions with different data, and in
some cases your code becomes so long that it’s hard to keep track of what each
part does. Functions serve as organization tools that keep your code neat and tidy.
In addition, functions make it easy to reuse the instructions you’ve created as
needed with different data. This section of the chapter tells you all about func-
tions. More important, in this section you start creating your first serious applica-
tions in the same way that professional developers do.
Do'stlaringiz bilan baham: |