3.2 Algorithms

You can solve any computing problem by executing a series of actions in a specific order. An algorithm is a procedure for solving a problem in terms of:

  1. the actions to execute, and

  2. the order in which these actions execute.

Correctly specifying the order in which the actions execute is essential. Consider the “rise-and-shine algorithm” that an executive follows for getting out of bed and going to work: (1) Get out of bed; (2) take off pajamas; (3) take a shower; (4) get dressed; (5) eat breakfast; (6) carpool to work. This routine gets the executive to work well prepared to make critical decisions. Suppose the executive performs these steps in a different order: (1) Get out of bed; (2) take off pajamas; (3) get dressed; (4) take a shower; (5) eat breakfast; (6) carpool to work. Now, our executive shows up for work soaking wet. Program control specifies the order in which statements (actions) execute in a program. This chapter investigates program control using Python’s control statements.

tick mark Self Check

  1. (Fill-In) A(n) ___________ is a procedure for solving a problem. It specifies the ___________ to execute and the ___________ in which they execute.
    Answer: algorithm, actions, order.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.193.232