Details

Learning Python with Raspberry Pi


Learning Python with Raspberry Pi


1. Aufl.

von: Alex Bradbury, Ben Everard

18,99 €

Verlag: Wiley
Format: EPUB
Veröffentl.: 11.02.2014
ISBN/EAN: 9781118717035
Sprache: englisch
Anzahl Seiten: 288

DRM-geschütztes eBook, Sie benötigen z.B. Adobe Digital Editions und eine Adobe ID zum Lesen.

Beschreibungen

<p><b>The must-have companion guide to the Raspberry Pi User Guide!</b></p> <p>Raspberry Pi chose Python as its teaching language of choice to encourage a new generation of programmers to learn how to program. This approachable book serves as an ideal resource for anyone wanting to use Raspberry Pi to learn to program and helps you get started with the Python programming language. Aimed at first-time developers with no prior programming language assumed, this beginner book gets you up and running.</p> <ul> <li>Covers variables, loops, and functions</li> <li>Addresses 3D graphics programming</li> <li>Walks you through programming Minecraft</li> <li>Zeroes in on Python for scripting</li> </ul> <p><i>Learning Python with Raspberry Pi</i> proves itself to be a fantastic introduction to coding.</p>
<p><b>Introduction 1</b></p> <p>What Is Programming? 1</p> <p>Why the Raspberry Pi? 2</p> <p>How Does this Book Work? 2</p> <p><b>Chapter 1 Getting Up and Running 5</b></p> <p>Setting Up Your Raspberry Pi 5</p> <p>Solving Problems 6</p> <p>A Quick Tour of Raspbian 7</p> <p>Using LXDE (Lightweight X11 Desktop Environment) 7</p> <p>Using the Terminal 8</p> <p>Changing Configurations with Raspi-Config 10</p> <p>Installing Software 10</p> <p>Python 3 11</p> <p>The Python Interpreter 11</p> <p>Running Python Programs 11</p> <p>Summary 12</p> <p><b>Chapter 2 A Really Quick Introduction to Python 13</b></p> <p>Drawing Picture with Turtles 13</p> <p>Using Loops 16</p> <p>Conditionals: if, elif, and else 18</p> <p>Using Functions and Methods to Structure Code 20</p> <p>A Python Game of Cat and Mouse 21</p> <p>Understanding Variables 24</p> <p>Defining Functions 24</p> <p>Looping Through the Game 25</p> <p>Summary 26</p> <p><b>Chapter 3 Python Basics 27</b></p> <p>Variables, Values, and Types 27</p> <p>Values Have Types 28</p> <p>Storing Numbers 29</p> <p>Keeping Text in Strings 30</p> <p>Boolean: True or False 31</p> <p>Converting Between Data Types 32</p> <p>Test Your Knowledge 32</p> <p>Exercise 1 33</p> <p>Storing Values in Structures 33</p> <p>Non-Sequential Values in Dictionaries and Sets 37</p> <p>Test Your Knowledge 38</p> <p>Controlling the Way the Program Flows 38</p> <p>Moving Through Data with for Loops 39</p> <p>Going Deeper with Nested Loops 40</p> <p>Branching Execution with if Statements 41</p> <p>Catching Exceptions 42</p> <p>Exercise 2 43</p> <p>Making Code Reusable with Functions 43</p> <p>Optional Parameters 46</p> <p>Bringing Everything Together 46</p> <p>Exercise 3 48</p> <p>Building Objects with Classes 49</p> <p>Getting Extra Features from Modules 54</p> <p>Summary 55</p> <p>Solutions to Exercises 56</p> <p>Exercise 1 56</p> <p>Exercise 2 56</p> <p>Exercise 3 56</p> <p><b>Chapter 4 Graphical Programming 57</b></p> <p>Graphical User Interface (GUI) Programming 58</p> <p>Adding Controls 60</p> <p>Test Your Knowledge 62</p> <p>Exercise 1 62</p> <p>Creating a Web Browser 62</p> <p>Adding Window Menus 71</p> <p>Test Your Knowledge 73</p> <p>Exercise 2 73</p> <p>Summary 74</p> <p>Solutions to Exercises 74</p> <p>Exercise 1 74</p> <p>Exercise 2 76</p> <p><b>Chapter 5 Creating Games 77</b></p> <p>Building a Game 79</p> <p>Initialising PyGame 82</p> <p>Creating a World 86</p> <p>Detecting Collisions 88</p> <p>Moving Left and Right 90</p> <p>Reaching the Goal 92</p> <p>Making a Challenge 93</p> <p>Making It Your Own 97</p> <p>Adding Sound 98</p> <p>Adding Scenery 99</p> <p>Adding the Finishing Touches 101</p> <p>Taking the Game to the Next Level 102</p> <p>Realistic Game Physics 103</p> <p>Summary 108</p> <p><b>Chapter 6 Creating Graphics with OpenGL 109</b></p> <p>Getting Modules 110</p> <p>Creating a Spinning Cube 110</p> <p>Vectors and Matrices 112</p> <p>Bringing It All Together 116</p> <p>Let There Be Light 120</p> <p>Calculating the Distance of the Point from the Light Source 120</p> <p>Calculating Reflecting Angles 121</p> <p>Making the Screen Dance 126</p> <p>Building the 3D Model 128</p> <p>Calculating the Sound Level 129</p> <p>Taking Things Further 135</p> <p>Adding Some Texture 136</p> <p>Summary 136</p> <p><b>Chapter 7 Networked Python 139</b></p> <p>Understanding Hosts, Ports, and Sockets 139</p> <p>Locating Computers with IP Addresses 140</p> <p>Building a Chat Server 141</p> <p>Tweeting to the World 144</p> <p>Weather Forecasts with JSON 147</p> <p>Testing Your Knowledge 149</p> <p>Exercise 1 149</p> <p>Getting On the Web 149</p> <p>Making Your Website Dynamic 151</p> <p>Using Templates 153</p> <p>Sending Data Back with Forms 153</p> <p>Exercise 2 155</p> <p>Keeping Things Secure 155</p> <p>Summary 159</p> <p>Solutions to Exercises 160</p> <p>Exercise 1 160</p> <p>Exercise 2 161</p> <p><b>Chapter 8 Minecraft 163</b></p> <p>Exploring Minecraft 164</p> <p>Controlling Your Minecraft World 164</p> <p>Creating Minecraft Worlds in Python 165</p> <p>Building Worlds 166</p> <p>Drawing Pictures 166</p> <p>Taking Things Further 169</p> <p>Making the Game Snake 169</p> <p>Moving the Snake 173</p> <p>Growing the Snake 173</p> <p>Adding the Apples 174</p> <p>Taking Things Further 175</p> <p>Summary 175</p> <p><b>Chapter 9 Multimedia 177</b></p> <p>Using PyAudio to Get Sound into Your Computer 177</p> <p>Recording the Sound 179</p> <p>Speaking to Your Pi 180</p> <p>Asking the Program Questions 181</p> <p>Putting It All Together 182</p> <p>Taking Things Further 184</p> <p>Making Movies 184</p> <p>Using USB Webcams 185</p> <p>Adding Computer Vision Features with OpenCV 187</p> <p>Taking Things Further 190</p> <p>Using the Raspberry Pi Camera Module 190</p> <p>Creating Live Streams 193</p> <p>Taking Things Further 196</p> <p>Summary 196</p> <p><b>Chapter 10 Scripting 197</b></p> <p>Getting Started with the Linux Command Line 197</p> <p>Using the Subprocess Module 200</p> <p>Command-Line Flags 202</p> <p>Regular Expressions 203</p> <p>Testing Your Knowledge 206</p> <p>Scripting with Networking 207</p> <p>Bringing It All Together 209</p> <p>Working with Files in Python 216</p> <p>Summary 217</p> <p><b>Chapter 11 Interfacing with Hardware 219</b></p> <p>Setting Up Your Hardware Options 219</p> <p>Female to Male Jumper Wires 219</p> <p>Pi Cobbler 220</p> <p>Solderless Breadboard 221</p> <p>Stripboards and Prototyping Boards 221</p> <p>PCB Manufacturing 222</p> <p>Getting the Best Tools 222</p> <p>Wire Cutters/Strippers 222</p> <p>Multimeters 222</p> <p>Soldering Irons 222</p> <p>Hardware Needed for this Chapter 223</p> <p>The First Circuit 224</p> <p>Protecting Your Pi 228</p> <p>Power Limits 229</p> <p>Getting Input 229</p> <p>Expanding the GPIO Options with I2C, SPI, and Serial 231</p> <p>The SPI Communications Protocol 231</p> <p>The I2C Communications Protocol 235</p> <p>The Serial Communications Protocol 236</p> <p>Taking the Example Further 236</p> <p>Arduino 236</p> <p>PiFace 237</p> <p>Gertboard 237</p> <p>Wireless Inventor’s Kit 238</p> <p>Trying Some Popular Projects 238</p> <p>Robots 238</p> <p>Home Automation 239</p> <p>Burglar Alarms 239</p> <p>Digital Art 239</p> <p>Summary 239</p> <p><b>Chapter 12 Testing and Debugging 241</b></p> <p>Investigating Bugs by Printing Out the Values 241</p> <p>Finding Bugs by Testing 245</p> <p>Checking Bits of Code with Unit Tests 245</p> <p>Getting More Assertive 250</p> <p>Using Test Suites for Regression Testing 252</p> <p>Testing the Whole Package 253</p> <p>Making Sure Your Software’s Usable 254</p> <p>How Much Should You Test? 254</p> <p>Summary 255</p> <p>Index 257</p>
<p><b>Alex Bradbury (Cambridge, UK)</b> is the Lead Software Developer on the Raspberry Pi.</p> <p><b>Russel Winder (London, UK)</b> was Professor of Computer Science at Kings College London and is the co-author of several tech books, including Developing Java Software and Python for Rookies. He lectures on Python at Skills Matter.</p>

Diese Produkte könnten Sie auch interessieren: