CHAPTER 3
Imperative Programming
3.2 Execution Control Structures
3.4 Python Variables and Assignments
3.6 Case Study: Automating Turtle Graphics
Solutions to Practice Problems
IN THIS CHAPTER, we discuss how to develop Python programs. A Python program is a sequence of Python statements that are executed in order. To achieve different program behavior depending on a condition, we introduce a few decision and iteration control flow structures that control whether and how many times particular statements are executed.
As we develop more code, we will note that, often, the same group of Python statements is used repeatedly and implements a task that can be described abstractly. Python gives developers the ability to wrap code into functions so the code can be executed with just one function call. One benefit of functions is code reuse. Another is that they simplify the developer's job by (1) hiding the code implementing the function from the developer and (2) making explicit the abstract task achieved by the code. In the chapter case study, we continue the use of turtle graphics to illustrate code reuse, information hiding, and functional abstraction.
The concepts covered in this chapter are fundamental programming language concepts, not just Python concepts. This chapter also introduces the process of breaking down problems into steps that can be described computationally using ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access