Teach Your Kids To Code: A Parent-friendly Guide to Python Programming
Turtle Graphics: Drawing with Python 15 Here is a step-by-step visual of the loop as x grows from 0 toward 100: for x in range(1 ...
16 Chapter 2 Turtle on a roll Let’s see what happens when we change one of the numbers in the program. One way to learn new thin ...
Turtle Graphics: Drawing with Python 17 This is also a nice visual to help you understand how being off by just one number can d ...
18 Chapter 2 CircleSpiral1.py import turtle t = turtle.Pen() for x in range(100): t.circle(x) t.left(91) Wow! Changing one comma ...
Turtle Graphics: Drawing with Python 19 A radius of x means that the diameter, or total width, of the circle will be two times x ...
20 Chapter 2 different colors with the Turtle library, including some weird ones like "salmon" and "lemon chiffon". (Visit http: ...
Turtle Graphics: Drawing with Python 21 The next thing we need to do is change the pen color every time we step through the draw ...
22 Chapter 2 every time x changes. In this case, our color list only has four colors, so we’ll rotate through these four colors ...
Turtle Graphics: Drawing with Python 23 c hanging Background colors Let’s mix things up a bit again to see if we can create some ...
24 Chapter 2 Always willing to help make my programs more awesome, Alex asked for one more change: what if we replaced the line ...
Turtle Graphics: Drawing with Python 25 o ne Variable to rule Them all So far, we’ve used variables to change the color, size, a ...
26 Chapter 2 a) b) c) d) e) Figure 2-8: Five colorful shapes created by changing the variable sides from 6 (a) down to 2 (e) ...
Turtle Graphics: Drawing with Python 27 What You Learned In this chapter, we drew impressive, colorful shapes in Python using th ...
28 Chapter 2 #2: How Many Sides? What if you want to let a user decide the number of sides while the program runs? Using what yo ...
Turtle Graphics: Drawing with Python 29 Figure 2-9: Adding an extra 90 degrees to each turn in ColorSpiral.py turns it into Rubb ...
...
3 numbers and Variables: Python Does the Math We’ve used Python to do really fun things, like make colorful pictures in just a f ...
32 Chapter 3 Variables: Where We Keep Our Stuff In Chapters 1 and 2, we used a few variables (you might remem- ber name from our ...
Numbers and Variables: Python Does the Math 33 you’ve listed two variables separated by a space). Third, variable names in Pytho ...
34 Chapter 3 Figure 3-1: A program with four variables and the output it creates Numbers and Math in Python The computer is grea ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf