Teach Your Kids To Code: A Parent-friendly Guide to Python Programming
Functions: There’s a Name for That 155 answer the questions “How many Ping-Pong balls tall am I?” and “What is my weight in Ping ...
156 Chapter 7 At u, we enter the two conversion formulas we developed. Both functions take an input parameter (inches and pounds ...
Functions: There’s a Name for That 157 ================================ RESTART ================================ Enter your h ...
158 Chapter 7 for the user to tell it what to do. We’re going to learn to handle user events and make our programs even more eng ...
Functions: There’s a Name for That 159 Figure 7-3: A TurtleDraw.py sketch (there’s a reason I’m an author and not an artist) The ...
160 Chapter 7 This is fine, because the program keeps running even while it’s lis- tening for mouse clicks, so by the time the u ...
Functions: There’s a Name for That 161 position to the location of that mouse click on the screen. The setpos() function is alre ...
162 Chapter 7 arrow keypresses. The final step is telling the computer to begin listening for keypresses, which we do with this ...
Functions: There’s a Name for That 163 Figure 7-5: The ArrowDraw.py program lets the user draw using the up, right, and left arr ...
164 Chapter 7 Figure 7-6: A smiley face drawn using the ClickSpiral.py app RandomSpiralsFunction.py (page 145) contained a funct ...
Functions: There’s a Name for That 165 In this new version, we change the function’s definition to reflect the new name and the ...
166 Chapter 7 t king a it one step Further: clickandsmile Let’s extend this interactive app by making one more change. Instead o ...
Functions: There’s a Name for That 167 t.begin_fill() t.circle(10) t.end_fill() Right eye t.setpos(x+15, y+60) t.begin_fill() t. ...
168 Chapter 7 Whatever kinds of apps you want to build, you’re probably going to rely on user interaction to drive the experienc ...
Functions: There’s a Name for That 169 draw_spiral(-x,y, size) draw_spiral(-x,-y, size) draw_spiral(x,-y, size) At u, we name ou ...
170 Chapter 7 This function takes the parameters x and y for the location to start drawing each spiral, and the parameter size t ...
Functions: There’s a Name for That 171 draw_spiral() function, followed by draw_kaleido(), and we finish by telling the computer ...
172 Chapter 7 What You Learned In this chapter, you learned how to organize chunks of reusable code into functions, call your ow ...
Functions: There’s a Name for That 173 Programming Challenges Here are three challenges to extend what you learned in this chapt ...
...
«
5
6
7
8
9
10
11
12
13
14
»
Free download pdf