Teach Your Kids To Code: A Parent-friendly Guide to Python Programming
Numbers and Variables: Python Does the Math 35 Floating-point, or decimal, numbers are great when we want fractions, like 3.5 mi ...
36 Chapter 3 Doing Math in the Python Shell This is a great time to give Python math a try; let’s use the Python shell this time ...
Numbers and Variables: Python Does the Math 37 s ntax y errors: What did you say? While we’re typing in the Python shell, we hav ...
38 Chapter 3 The fact that we can rely on a computer to answer correctly and quickly every time we give it proper input is one o ...
Numbers and Variables: Python Does the Math 39 Notice that in the last assignment statement, we used x on both sides of the equa ...
40 Chapter 3 Calculate the total cost of the pizzas as our subtotal. Calculate the sales tax owed, at 8 percent of the subtotal ...
Numbers and Variables: Python Does the Math 41 Add the sales tax to the subtotal for the final total total = subtotal + sales_ta ...
42 Chapter 3 When you’ve written your program, you can run it and inter- act with it by going to Run 4 Run Module. Figure 3-5 sh ...
Numbers and Variables: Python Does the Math 43 SayMyName.py SayMyName.py - prints a screen full of the user's name Ask the user ...
44 Chapter 3 of the current line without returning, or starting a new line, until the current line fills up completely and wraps ...
Numbers and Variables: Python Does the Math 45 the power of strings with colorful turtle graphics. Let’s give it a try! In the f ...
46 Chapter 3 Figure 3-8: A colorful text spiral l sts: Keeping i it all together In addition to strings and number values, varia ...
Numbers and Variables: Python Does the Math 47 function asked the user for a string, turtle.numinput() allows the user to enter ...
48 Chapter 3 Finally, at x, we increase the width or thickness of the pen as we get farther from the center of the screen. Figur ...
Numbers and Variables: Python Does the Math 49 you’d type 4 ** 2. Here’s what our program, MathHomework.py, looks like when we p ...
50 Chapter 3 get the remainder, we use the modulo operator, which we repre- sent in Python with the % symbol. Don’t confuse % wi ...
Numbers and Variables: Python Does the Math 51 words, letters, characters, and sym- bols, including how to make Python understan ...
52 Chapter 3 Programming Challenges To practice what you’ve learned in this chapter, try these challenges. (If you get stuck, go ...
4 loops are Fun (You Can say that again) We’ve used loops since our very first program to draw repeating shapes. Now it’s time t ...
54 Chapter 4 Figure 4-1: A four-circle rosette pattern Let’s think about how we might write a program to draw four circles overl ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf