“91974˙CH01˙ﬁnal” — 2012/12/14 — 13:55 — page 42 — #42
42 CHAPTER 1 Introduction
1.42 Modify the drawCircle function so that the circle is drawn with the center at the
turtle’s present position.
1.43 The drawCircle function is somewhat ineﬃcient: for small circles, 360 sides is really
overkill and for very large circles 360 sides might be too few. See if you can devise a
way to make the number of sides and turning angle dependent on the radius so that
smaller circles use fewer sides and larger circles use more.
This chapter introduced the following fundamental building blocks of programming and
Using modules and functions provided by Python
Writing your own functions to extend the functionality provided by Python
In addition, the approach we followed to use the turtle to draw a circle illustrates an
important problem-solving pattern that you will use many times as you progress through
this book. That pattern can be summarized as follows:
Simplify in order to understand the problem better.
Generalize to solve many problems with one function.
Build on what you have learned to solve more complex problems.
In subsequent chapters we will continue to use these basic building blocks. There will be
more tools to add to your toolbox. We have glossed over a few details on some of the
ideas introduced in this chapter but will return to them later. Keep in mind the idea
behind this book: to focus on problem solving while continually adding to your knowledge
of programming and computer science.