199C O M P U T E R L A N G U A G E S    Languages from the past                                             REAL WORLD    Many languages that were famous twenty or thirty years        Millennium bug  ago have fallen in popularity, despite still being used in  some very important systems. These languages are often        Many programs in older languages  seen as difficult to code by modern standards.                like COBOL used two digits to                                                                represent a year (such as 99 for  BASIC    Designed in 1964 at Dartmouth College, in the        1999). The “millennium bug” was           US, BASIC was very popular when home                 predicted to cause problems in           computers first became available.                    2000 when these dates rolled over                                                                into the new millennium as 00.    Fortran  Designed in 1954 at IBM, a technology firm, Fortran   Computers all over           is mainly used for calculations on large computers.  the world had to be           It is still being used in weather forecasting.       updated to prevent                                                                the millennium bug    COBOL    Designed in 1959 by a committee of experts,           COBOL is still being used in many business and           banking programs.    Weird languages                         (‘&%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@>a=<M:9[p6tsl1TS/                                          QlOj)L(I&%$””Z~AA@UZ=RvttT`R5P3m0LEDh,T*?(b&`$#87[}{W  Among the thousands of languages are  a few that have been created for very  △ Malbolge  specific and strange purposes.         The Malbolge language was designed to be impossible to                                         program. The first working code did not emerge until two                                         years after its release, and was written by another program.    △ Piet                                 △ Chef                         △ Ook!  Programs created in Piet code look  like abstract art. The “Hello World!”  A program written in Chef is   Designed to be used by  program is shown above.                meant to resemble a cooking    orangutans, Ook! has only three                                         recipe. However, in practice,  elements: “Ook”, “Ook!”, and                                         the programs rarely produce    “Ook?” These can be combined                                         useful cooking instructions.   to create six commands, such                                                                        as “Ook! Ook” and “Ook? Ook!”
200 P R O G R A M M I N G I N T H E R E A L W O R L D                                                                                                                                                            SEE ALSO    Coding stars                                                                                                                                                                                                      18–19 Becoming    Computing is driven forward every day by millions of                                                                                                                                                             a coder  programmers all around the world, but every now and  then someone special comes along and takes a massive                                                                                                                                                              Computer 204–205  leap. Here are a few of the most famous coders.                                                                                                                                                                          games               Ada Lovelace                                                                                                                                                                                                         Alan Turing    Nationality: British                                                                                                                                                                                                  Nationality: British   Dates: 1815–52                                                                                                                                                                                                      Dates: 1912–54   FccIfaBnoEocisrmrannouems1bogtsmpg8piubiprgd4npseuaree3efusogtsr,oeetgee(tsrenrae’:drhsrptadApe)iAtm.rndromopSnogaghufbapeocLrelbetoyahrohlsatmtiaCvoieshlcreshhddmeaaolaesacleferdtciflarreoee.strrrshtlsiyse                                                                                                                                                                                                                   tWGhcgHfreeoArFaaeroraBltcml’ahsumdkrnienaaitoWnrinTldussguoa-shocbrrfsf.oiforecInadeIrocgm:faermoMkesiorsitpdnaukutugsnhtrfoweeionrwmorgsnrhackitiaseicsnitachnee.      as numbers.                                                                                                                                                                                                                        Bill Gates and Paul Allen             Grace Hopper                                                                                                                                                                                                                     Nationality: American   Nationality: American                                                                                                                                                                                                                     Dates: Gates 1955–present, Allen 1953–present   Dates: 1906–92                                                                                                                                                                                                                     Famous for: Bill  Famous for: Grace Hopper created                                                                                                                                                                                   Gates and Paul  the first programming language                                                                                                                                                                                      Allen founded  compiler (which transforms human                                                                                                                                                                                    Microsoft together  readable programs into machine                                                                                                                                                                                      in the 1970s. They  code). As well as being a                                                                                                                                                                                           invented some of  computer scientist                                                                                                                                                                                                  the most popular  she was a Rear                                                                                                                                                                                                      programs ever, such as  Admiral in the                                                                                                                                                                                                      Microsoft Windows  US Navy!                                                                                                                                                                                                            and Office.
201C O D I N G S T A R S      Gunpei Yokoi and Shigeru Miyamoto                                                                                           Tim Berners-Lee     Nationality: Japanese                                                                                                Nationality: British                                                                                                                        Dates: 1955–present   Dates: Yokoi 1941–97, Miyamoto 1952–present                                                                           FCrTtaaeEhimnmsReedoNaWBumrse(coafarhrondflrdacee:merWWsinto-ithLfduereielerseeeisWniwcnfeioSovebwrern,kntitiitnfzeiegcdralatnd),   Famous for: Yokoi and   Miyamoto worked for                                                                                                    ekEvnlieizgrayhboteentdeh.bIHIyienQw2ua0es0e4n.  Nintendo, the gaming  company. Yokoi  invented the Game  Boy, while Miyamoto  made successful games  such as Super Mario.    Larry Page and Sergei Brin                                                                                            Mark Zuckerberg    Nationality: American                                                                                                 Nationality: American    Dates: Both 1973–present                                                                                                                    Dates: 1984–present    FPwbasTasrmeeohegeacroaevekrouroicracmsohlhnuefneoefdtmfirwnteo:BhgecnIhrnettiiianhinzvG1teeoeb9wo.dd9eoo6ggu,allend                         Famous for: Zuckerberg    the Internet.                                                                                                                              launched Facebook from his                                                                                                                                               college room in 2004.                                                                                                                                               Facebook has since become                                                                                                                                               a billion-dollar company, and                                                                                                                                               made Zuckerberg one of the                                                                                                                                               wealthiest people alive.                                                                                                                          Open Source Movement                                                                                                                          Nationality: All                                                                                                                          Dates: Late 1970s–present                                                                                                                        Fpbfoaorepmorefgmorreuraaaestmnifanoynmgrsd: iesTgayrhnvsseatiafeioirlcmaopabuenalnnetndptsdootieWhuacelrileck.wsTeiphoomeefrdlosdmiovawofe,tvmthwheoeaemnrboeete,nnilsslitieunhavceaehcsoesabnlolseecftetcyhwntceilaoroeGrnpesNeopsUdfohi/noaLsu.iinbldulex
202 P R O G R A M M I N G I N T H E R E A L W O R L D                                  SEE ALSO    Busy programs                                                                           180–181 Inside    Computers and programs have become an invisible                                        a computer  part of daily life. Every day, people benefit from very  complex computer programs that have been written                                        192–193 Storing  to solve incredibly tough problems.                                                                                         data in files    Compressing files                                                                            REAL WORLD    Almost every type of file that is sent over the Internet                               Music files  is compressed (squeezed) in some way. When a file is  compressed, data that isn’t needed is identified and                                   Without music compression  thrown away, leaving only the useful information.                                      programs, you could only fit a                                                                                         few songs on your music player.                                                               ◁ Squeezing data          By compressing audio files, the                                                                  Compressing a file is  average smartphone can now                                                                  like squeezing a       hold thousands of songs.                                                                  jack-in-the-box to                                                                  make it fit into a                                                                  smaller space.    Secret codes                                                                           ◁ Cryptography    When you log in to a website,                                                          Cryptography is the  buy something, or send a                                                               study of codes. Complex  message across the Internet,                                                           mathematical codes  smart programs scramble your                                                           scramble and unscramble  secret data so that anyone who                                                         personal data to keep it  intercepts it won’t be able to                                                         safe from thieves.  understand it. Global banking  systems rely on these advanced  programs capable of hiding  secret information.
203B U S Y P R O G R A M S    Artificial Intelligence            △ Medicine                     △ Bomb disposal    Intelligent programs do more       Systems are able to analyze a  Many soldiers’ lives can be  than just make computer games      huge database of medical       saved by using an intelligent  fun. Artificial Intelligence (AI)  information and combine it     robot to safely dispose of a  is being used to provide better    with details from the patient  bomb in an area that has been  healthcare, as well as helping     to suggest a diagnosis.        cleared of people.  robots operate in places too  dangerous for humans to go,  such as war zones and areas  destroyed by natural disasters.    Supercomputers                                                          REAL WORLD    Supercomputers—used by high-tech organizations such               Weather forecast  as NASA—combine the power of thousands of computer  processors that share data and communicate quickly. The           Weather patterns are very  result is a computer that can perform millions of                 unpredictable. Supercomputers  calculations per second.                                          crunch the huge amounts of data                                                                    needed to accurately predict what      2 Computer     3 Each processor works on                      will happen. Each processor in the  breaks problem     one of the smaller problems                    supercomputer calculates the                                                                    weather for a small part of the map.      into smaller,                 4 Each sub-problem is           All the results are then combined    sub-problems                    solved separately               to produce the whole forecast.                                                      5 Computer                                                    puts results                                                    back together    1 Complex problem                  6 Final result appears  is entered into                                much faster  supercomputer    △ How it works  Problems are broken into smaller problems that are all worked  on separately at the same time by different processors. The  results are then combined together to give the answer.
204 P R O G R A M M I N G I N T H E R E A L W O R L D                                  SEE ALSO    Computer games                                                                          200–201 Coding    What does it take to make a modern video game?                                         stars  All computer games are a different mix of the same  ingredients. Great games are usually made by teams                                        Making 206–207  of software developers—not just programmers.                                                     apps    Who makes computer games?    Even simple games on your mobile phone might be made by large  teams of people. For a game to be popular and successful, attention  to detail needs to be given to every area during its development,  which involves many people with lots of different skills.    △ Coder                                                ◁ Level designer                △ Graphic designer  Programmers write the  code that will make the                                The architects of the game’s    All of the levels and  game work, but they can                                virtual world, level designers  characters need to  only do this with input                                create settings and levels      look good. The graphic  from the rest of the team.                             that are fun to play.           designers define the                                                                                         structure and appearance  △ Scriptwriter                                                                         of everything in the game.  Modern games have  interesting plots just like  ▷ Tester                        LINGO  great books and films.  Scriptwriters develop        Playing games all         Consoles  all the characters and       day may seem like a  stories for the game.        great job, but testers    A console is a special type of                               often play the same       computer that is well suited to                               level over and over       running games. Consoles, such as                               again to check for bugs.  the PS4 and Xbox One, often have                                                         advanced graphics and sound                                                         processors capable of running                                                         many things at once, making                                                         more realistic games possible.                                 ◁ Sound designer                                 Just like a good movie,                               a great game needs                               to have quality music                               and sound effects to                               set the mood.
COMPUTER GAMES  205    Game ingredients    The most common ingredients in games are often combined  into a “game engine”. Engines provide an easy-to-use base so  that new games can be developed quickly.    ▷ Story and game logic    All games must have a good  story and some sort of goal  to aim for, such as saving the  princess. Well-designed game  logic keeps players interested.                              ◁ Game physics                                           △ Graphics                             In a virtual world, the rules of the                     As games become more realistic their                             real world, such as gravity and                          graphics must become more complex.                             collisions, must be re-created to                        Body movements, smoke, and water are                             make the game more believable.                           particularly hard to get right.    ▷ Controls                                                       ▷ Sound  Familiar controls that make sense to                             All of the words spoken in the  the player help make a great game.                               game must be recorded, as well  Good control design makes the player                             as the background music and  forget that they are using a controller.                         the sound effects that change                                                                   throughout the game.             Open the pod bay               doors, Hal     I’m sorry Dave, I’m                              REAL WORLD  afraid I can’t do that                                              Serious games    △ Artificial intelligence                   Games are being used for                                              more than just fun. Pilots,  Human players often play alongside or       surgeons, and soldiers are just  against computer-controlled players.        some of the professionals  Artificial intelligence programming allows  who use games at work for  these characters to respond realistically.  training purposes. Some                                              businesses even use strategy                                              games to improve their                                              employees’ planning skills.
206 P R O G R A M M I N G I N T H E R E A L W O R L D                               SEE ALSO    Making apps                                                                          190–191 Essential    Mobile phones have opened up a world of possibilities                               programs  for coders. With a computer in everyone’s pocket, mobile  apps can use new inputs, such as location-finding and                                198–199 Computer  motion-sensing, to give users a better experience.                                                                                      languages  What is an app?                                                                                       204–205 Computer  “App” (short for “application”) is a word that describes  programs that run on mobile devices, including                                      games  smartphones, tablets, and even wearable technology  such as watches. There are many different categories                                ◁ Social network  of apps that do different things.                                                   Social apps can allow                                                                                      people to connect with                            ◁ Games                                                   friends, whether they are                             All sorts of games are available on mobile               nearby or far away, to                             devices, from simple puzzle games to                     share thoughts, pictures,                             fast-paced action adventures.                            music, and videos.    △ Weather                                                                           △ Travel  Mobile apps use your location to                                                    Travel apps use your location  provide accurate weather forecasts,                                                 combined with other users’ reviews  and also allow you to check the                                                     to provide recommendations for  weather around the world.                                                           restaurants, hotels, and activities.                                              ◁ Sport                                   △ Education                                              People use apps to track their fitness  Educational apps are great for                                              when running or cycling, and can also   learning. Young children can learn                                              keep up to date on the latest sports    to count and spell, and older                                              scores while on the go.                 people can learn a new language.
207M A K I N G A P P S    How to build an app    There are many questions to answer before  building an app. What will it do? What devices will  it run on? How will the user interact with it? Once  these questions are answered, building an app  is a step-by-step process.           Mac                                       1 Have an idea                                                          Any idea for a new app must be well suited to       Android                                     mobile devices. It might be a completely new idea,                                                   or it could just be an improvement on an already       Windows                                     existing idea to make a better version.    2 Which operating system?                                3 Learn to make apps         Will the app target a certain type of                           Whichever platform the app will run on,  mobile device? Coders can often use tools that                 a coder needs to learn the language and other  let them write their application once and then                 skills needed to build a good app. Online  adapt it for different operating systems.                      tutorials and local coding clubs can help.    4 Create the program                             5 Test it         Good apps take time to make. A basic             Users will quickly get rid of an app if it contains  version might be working in weeks, but for an    bugs. Putting in tests as part of the code, and getting  app to be really successful, it will need to be  friends and family to try out the app can help clean  developed for a few months before its release.   up any errors before the app is released.
208 P R O G R A M M I N G I N T H E R E A L W O R L D       SEE ALSO    Programming                                                  198–199 Computer  for the Internet                                                              languages  Websites are built using coding languages that work  just like Python. One of the most important of these             Using 210–211  is JavaScript, which makes websites interactive.                                                                   JavaScript  How a web page works                              CSS                                                              ◁ CSS  Most web pages are built using several                      The language CSS  different languages. An email website, for                  (Cascading Style  instance, is made with CSS, HTML, and                       Sheets) controls the  JavaScript. The JavaScript code makes the                   colors, fonts, and  site respond instantly to mouse clicks                      layout of the page.  without having to reload the page.    INBOX      CONTACTS  CALENDAR    Compose ▼  Delete                           + Move    Inbox      ▢ Sam                       Funny cat video  Drafts     ▢ Lizzie                    Presents for Ben  Sent       ▢ Fiona                     Lunch?  Spam       ▢ Shaila                    No thanks  Trash      ▢ Paula                     Come to my party?             ▢ Dan                       Re: Barnyard dance             ▢ Ben                       Re: Amazing picture  JavaScript             ▢ Sarah                     Hockey match             ▢ Vicky                     Re: New York             ▢ Ella                      Book review             ▢ Phil                      Ben’s presents    HTML                 ◁ HTML                                 ▷ JavaScript                         HTML (HyperText Markup                 JavaScript controls how the                       Language) builds the basic             page changes when you use                       structure of the page, with            it. Click on an email, for                       different sections that                instance, and JavaScript                       contain text or images.                makes a message open up.
209P R O G R A M M I N G F O R T H E I N T E R N E T    HTML                                   <html>                                              Blocks of text are surrounded by “tags”, a                                          <head>                                             very common feature in HTML code. This  When you open a website, your                                                              tag gives the window a title  Internet browser downloads an  HTML file and runs the code to turn                  <title>The Hello World Window</title>  it into a web page. To see how it  works, type the code here into an                    </head>  IDLE code window (see pp.92–93)  and save it as a file with the ending                <body>  “.html”. Double click the file and it  will launch a browser window                         <h1>Hello World in HTML</h1>  saying “Hello World!”                                                       <p>Hello World!</p>                           The “<p>” and “</p>”                                                                                                     tags surround                                          </body>                              This tag shows where  ordinary paragraphs                                         </html>                               the HTML code ends    Trying JavaScript                                                                  EXPERT TIPS    It’s easy to experiment with JavaScript                                      Games in JavaScript  because all modern web browsers can  understand it. JavaScript code is usually placed                             JavaScript is so good at  within HTML code, so the example below uses                                  creating interactive features  two coding languages at once. The JavaScript                                 that it can be used to make  section is surrounded by “<script>” tags.                                    games—from simple                                                                               puzzles to fast-paced racing  1 Write some JavaScript                                                      games. These will work in         Open a new IDLE code window and type out                              any modern web browser, so  the code below. Check the code very carefully. If                            there’s no need to install  there are any errors, you’ll just see a blank page.                          the game first. JavaScript                                                                               is also used to create web  <script>   The “<script>” tag                                                apps such as webmail or             introduces JavaScript code                                        interactive calendars.    alert(“Hello World!”);    </script>  The “alert” command will             make an alert box pop up    2 Save your file                                                             3 Pop-up appears         Save the file and enter a filename such as “test.html”                      The browser will open and an interactive alert box  so the code is saved as an HTML file and not a Python file.  Then double click the file to test it.                                       will pop up with the greeting “Hello World!” Click “OK” to            test.html                                                            dismiss the box.                                                     Don’t forget to give your                                  JavaScript                                                   filename an “.html” ending                                                                                                              creates                                                                                                                interactive                                                                                 JavaScript                     features such                                                                                                              as buttons                                                                               Hello World!                                                                                                       OK
210  PROGRAMMING IN THE REAL WORLD    Using JavaScript                                                                       SEE ALSO    JavaScript is great for creating mini programs that run                                 162–163 Reacting  inside HTML, bringing websites to life and allowing users  to interact with them. Although it works like Python,                                  to events  JavaScript code is more concise and trickier to learn.                                                                                          122–123 Loops                                                                                           in Python                                                                                            208–209 Programming                                                                                           for the Internet    Getting input                                                     This line creates a  The text in quotes                                                                    pop-up box and       appears in the box  As with Python, you can use JavaScript to ask the user            stores the text the  for information. JavaScript can do this with a pop-up             user types into it  box. The following program prompts the user to  enter their name and responds with a greeting.    1 Use a prompt                <script>         This short script  stores the user’s name in a   var name = prompt(“Please enter your name”);  variable. Type the code into  the IDLE code window and      var greeting = “Hello ” + name + “!”;  remember to save it with a  “.html” filename.             document.write(greeting);                                JavaScript lines                                </script>                                                always end with                                                                                         a semicolon    The “</script>” tag shows     This line displays                         EXPERT TIPS  where the JavaScript ends          the greeting                                                                     Type carefully  2 Question appears         Double-click the HTML file to launch                        When working with JavaScript, be  a browser window. Enter your name in the                           careful to check that you’ve typed  box and click “OK” to see the greeting.                            out the code correctly. If there’s an                                                                     error, the browser will simply  JavaScript                                        A prompt box     ignore the whole block of                                                    always has “OK”  JavaScript and  Please enter your name                            and “Cancel”     will create a                                                    buttons          blank window,   Charlie                                                           without any error                                                                     message saying                             OK Cancel              The greeting     what went wrong.                                                    appears in the   If that happens,                                       <>           browser          check the code                                                    window           again carefully.                                  Hello Charlie!
211U S I N G J A V A S C R I P T    Events                        1 Type the code                                       In this example, an event (clicking a button) triggers a  An event is any action        simple function (a tongue-twister appears). Type the code in  that a program can            an IDLE code window and save the file with a “.html” ending.    detect, such as a mouse    click or a keystroke. The <button onclick=“tonguetwist()”>Say this!</button>    section of code that                     <script>                         Name of the function    HTML code links the  reacts to an event is                                                                             function to a button  called an “event handler”.               function tonguetwist()  Event handlers are used a                                           {          Curly brackets surround a block of code—they                                                      work in a similar way to indents in Python    lot in JavaScript and can                document.write(“She sells seashells”);    trigger many different                   }    functions, making web                    </script>                                                JavaScript code                                                                                                    defines the function  pages fun and interactive.                                  Click the                                                                 The tongue-twister                                  button                                                                  appears    2 Run the program             <>                                               <>         Double-click the file  to launch the program in a        Say this!                                     She sells seashells  browser window.    Loops in JavaScript                                                            2 Loop output                                                                                        Save the code as a “.html” file and run  A loop is a section of code that repeats. Using                                it. The loop keeps repeating as long as “x”  loops is much quicker and easier than typing                                   is less than 6 (“x<6” in the code). To  out the same line of code over and over again.                                 increase the number of repeats, use a                                                                                 higher number after the “<” symbol.  1 Loop code         Like Python, JavaScript uses “for” to set up a loop. The repeated  lines of code are enclosed in curly brackets. This loop creates a simple  counter that increases by one each time it repeats.    <script>   The “<script>” tag introduces                                       <>             the JavaScript code                                                                                  Loop count: 0  for (var x=0; x<6; x++)                      This line creates a counter        Loop count: 1     The loop  {                                            called “x” with a starting value   Loop count: 2     repeats six times                                               of 0, rising by 1 in each repeat   Loop count: 3                                                                                  Loop count: 4  document.write(“Loop count: “+x+”<br>”);                                        Loop count: 5    }                                        This line tells the computer to  </script>                                write the text “Loop count:”                                           followed by counter number
212  PROGRAMMING IN THE REAL WORLD    Bad programs                                              SEE ALSO    Not all programs are fun games or useful apps. Some        194–195 The  programs are designed to steal your data or damage  your computer. They will often seem harmless, and         Internet  you might not realize that you have been a victim.                                                             202–203 Busy                                                              programs    Malware                                                   △ Virus    Programs that do things without your knowledge or         Just like a virus in the human body,  permission are known as “malware”. Unauthorized           this malware copies itself over and over  access to a computer is a crime, but there are many       again. They are usually spread through  different types of programs that still try to sneak on    emails, USB sticks, or other methods of  to your computer.                                         transferring files between computers.    ▷ Worm  A worm is a type of malware that crawls around a  network from computer to computer. Worms can clog  up networks, slowing them down—the first worm  brought the Internet to a virtual standstill in 1988.    △ Trojan                                                        REAL WORLD    Malware that pretends to be a harmless program is         Famous worm  known as a “trojan”. The word comes from a ruse used  in the Trojan War: the Greeks gave the Trojans a giant    On May 5, 2000, Internet users in the Philippines  wooden horse, with soldiers hidden inside. By breaching   received emails with the subject “ILOVEYOU”. An  the Trojan defenses without detection, they won the war.  attachment appeared to be a love letter, but was                                                            actually a piece of malware that corrupted files.                                                                                              ◁ ILOVEYOU                                                                                             This worm quickly spread                                                                                             to computers around the                                                                                             world. It is estimated to                                                                                             have cost more than $20                                                                                             billion to fix the damage                                                                                             it caused.
213B A D P R O G R A M S    What malware does    Viruses, worms, and trojans are all types  of malware that are created to get into your  machine, but what do they do once they  have infected their target? They might  delete or corrupt files, steal passwords,  or seek to control your machine for  some larger purpose as part of an  organized “zombie botnet”.    ▷ Zombie botnets                                                            LINGO  Botnets are collections of infected  computers that can be used to send                                    Hackers  spam emails, or flood a target website  with traffic to bring it crashing down.                               Coders that study and write                                                                        malware are known as “hackers”.  Good software to the rescue                                           Those who write malware to                                                                        commit crimes are known as  Thankfully, people aren’t defenseless in the fight against            “black-hat” hackers, and those  malware. Anti-malware software has become big                         who write programs to try to  business, with many providers competing to provide                    protect against malware are  the best protection. Two well-known examples are                      known as “white-hat” hackers.  firewalls and antivirus programs.    △ Antivirus programs                △ Firewalls                       White-hat hacker  Black-hat hacker    Antivirus software tries to detect  Firewalls aim to prevent malware  malware. It identifies bad          and dangerous network traffic  programs by scanning files and      from reaching your computer.  comparing their contents with a     They scan all incoming data  database of suspicious code.        from the Internet.
214  PROGRAMMING IN THE REAL WORLD    Mini computers                                                       SEE ALSO    Computers don’t have to be big or expensive. A wide                   180–181 Inside  range of small and cheap computers are available.  Because of their small size and low cost, these computers            a computer  are being used in lots of new and exciting ways.                                                                        202–203 Busy                                                                         programs    Raspberry Pi                                                         LED lights show                                                                       the Pi is working  The Pi is a credit-card-sized computer, created to teach the basics  of how computers work. For its size it is impressively powerful,              Two USB connectors for  with the ability to run similar programs to a modern PC.                      a mouse, a keyboard, or                                                                                any other add-ons                                               Audio output for                                     headphones or speakers                             Video output for                                     older TVs     Input and output pins  for sensing and control           (good for robots)     Removable memory                                                                           Network connection to  card stores operating                                                                       access the Internet      systems, programs,                                              HDMI video output—to                 and data                                           connect to modern TVs                              Power connector    Arduino                                    Many input and output                      Microcontroller—a                                             pins make the Arduino                      single-chip computer    The Arduino is cheaper than                very adaptable    the Pi, but less powerful. It    is often used as a low-cost                Reset button  and simple way to build    custom electronic or    robotic machines.                                                                     Sockets for                                                                                        connecting the            USB connector used to                                                       Arduino to other           load programs on to the                                                      electronics                    Arduino from a PC                                    Power connector
MINI COMPUTERS  215    Using mini computers    There are endless useful things a mini computer can do because of  its many connection options. Here are just a few suggestions.    △ Computer                    △ Audio output             △ Mobile phones            △ Gadgets  Connect a keyboard, mouse,    Connect a set of speakers  Connect the computer       Connect LED lights and  and monitor for a fully       and then send music to     to the Internet using a    other simple electronics to  working desktop computer.     them over the network.     mobile phone.              make robots or gadgets.    △ Television                  △ Camera                   △ USB                      △ SD card  Connect a TV and use it as a  Connect a basic camera     Connect a USB hard drive   Change the programs on  media center to show all of   to your mini computer to   and share your files over  your mini computer just  your movies and pictures.     create your own webcam.    your network.              by swapping SD cards.          REAL WORLD                       Robotic spider controlled                                                      by the Arduino  Home-built robots    With their small size, cost, and  weight, mini computers are  being used more and more to  build different types of robot.  For example:    Weather balloons that record  weather conditions in the atmosphere.    Mini vehicles that can sense  obstacles using sonar like a bat.    Robotic arms that pick up and  move different objects.
216  PROGRAMMING IN THE REAL WORLD    Become a master                                                          SEE ALSO  programmer                                                                         176–177 What next?  The secret to becoming a master programmer is to                       214–215 Mini  have fun. As long as you’re enjoying yourself, there’s  no limit to how skilled you can become at coding,                        computers  whether as a hobby or a lifelong career.                                                                     △ Code a lot  Ways to become a better programmer                                 People say practice makes                                                                     perfect—and it’s true. The  Like skiing, learning the piano, or playing tennis, coding is a    more code you write, the  skill that you’ll get better and better at over time. It can take  better you’ll get. Keep going  years to become a true expert, but if you’re having fun on         and you’ll soon be an expert.  the way, it will feel like an effortless journey. Here are a few  tips to help you become a master programmer.         ◁ Be nosy                          △ Steal ideas         Read websites and books about      If you come across a great program, think how you       programming and try out other      might code it yourself. Look for clever ideas to use       people’s code. You’ll pick up      in your own code. All the best programmers copy       expert tips and tricks that might  each other’s ideas and try to improve them.       have taken you years to figure       out on your own.    ▷ Show a friend              ▷ Train your brain    Teach someone else to        Your brain is like a muscle—  code and you’ll learn a lot  if you exercise it, it will get  yourself. Explaining how     stronger. Do things that  coding works is a great      help you think like a  way of making sure you       programmer. Solve logic  understand it thoroughly.    puzzles and brainteasers,                               take up Sudoku, and work                               on your math.
BECOME A MASTER PROGRAMMER  217    ▷ Test your code                                      Scala Pascal SQL                                                       Ruby on rails C++  Test your code by entering crazy  values to see what happens. See  how well it stands up to errors.  Try rewriting it to improve it or  try rewriting someone else’s—  you’ll learn all their secret tricks.                     ◁ Build a robot army                         △ Learn new languages                   You can connect your computer                Become multilingual. Every new programming                   to all sorts of programmable                 language you learn will teach you more about the                   devices, from flashing LED                   ones you already know (or thought you knew). You                   lights to robots. It’s fun and               can download free versions of most languages.                   you’ll learn lots as you figure                   out how to conquer the world.       ▷ Win a prize                                                       When your skills develop,  ▷ Pull a computer to bits                            why not enter an online  Take an old computer apart                           coding contest? There are lots  to see how it works (ask                             to choose from at all different  permission first!). There                            levels. The toughest are  aren’t many components,                              worldwide competitions like  so it won’t take long to                             Google’s Code Jam, but there  figure out what all the bits                         are easier challenges too.  are. Best of all, build your  own computer and then  run your code on it.             REMEMBER     Have fun!      Coding is a lot like trying to solve puzzles.    It’s challenging and you’ll often get stuck.    Sometimes it’s frustrating. But you’ll also    have breakthroughs when you solve a    problem and feel a buzz of excitement    at seeing your code work. The best way to    keeping coding fun is to take on challenges    that suit you. If a project is too easy you’ll    get bored; if it’s too hard you’ll lose interest.    Never be afraid to fiddle, tinker, experiment,    and break the rules—let your curiosity lead    you. But most of all, remember to have fun!
218 R E F E R E N C E    Glossary    algorithm                    call                       event                        GUI  A set of step-by-step        To use a function in a     Something a computer         The GUI, or graphical user  instructions followed        program.                   program can react to, such   interface, is the name for  when performing a                                       as a key being pressed or    the buttons and windows  task: for example, by a      compression                the mouse being clicked.     that make up the part of  computer program.            A way of making data                                    the program you can see                               smaller so that it takes   execute                      and interact with.  ASCII                        up less storage space.     See run.  “American Standard                                                                   hacker  Code for Information         computer network           file                         A person who breaks  Interchange”—a code used     A way to link two or more  A collection of data stored  into a computer system.  for storing text characters  computers together.        with a name.                 “White hat” hackers work  as binary code.                                                                      for computer security                               container                  float                        companies and look for  binary code                  A part of a program        A number with a decimal      problems in order to fix  A way of writing numbers     that can be used to        point in it.                 them. “Black hat” hackers  and data that uses only      store a number of                                       break into computer  0s and 1s.                   other data items.          function                     systems to cause harm or                                                          A piece of code that does    to make profit from them.  bit                          data                       part of a larger task.                                                                                       hardware  A binary digit—0 or 1.       Information, such as       gate                         The physical parts of a  The smallest unit of         text, symbols, and         Used by computers to         computer that you can  digital information.         numerical values.          make decisions. Gates        see or touch, such as wires,                                                          use one or more input        the keyboard, and the  Boolean expression           debug                      signals to produce an        display screen.  A question that has only     To look for and correct    output signal, based on  two possible answers, such   errors in a program.       a rule. For example, “AND”   hexadecimal  as “true” and “false”.                                  gates produce a positive     A number system based on                               debugger                   output only when both        16, where the numbers 10  branch                       A program that checks      input signals are positive.  to 15 are represented by  A point in a program where   other programs for errors  Other gates include “OR”     the letters A to F.  two different options are    in their code.             and “NOT”.  available to choose from.                                                            index number                               directory                  GPU                          A number given to an  bug                          A place to store files to  A graphics processing        item in a list. In Python,  An error in a program’s      keep them organized.       unit (GPU) allows images     the index number of the  code that makes it behave                               to be displayed on a         first item will be 0, the  in an unexpected way.        encryption                 computer screen.             second item 1, and so on.                               A way of encoding data so  byte                         that only certain people   graphics                     input  A unit of digital            can read or access it.     Visual elements on a         Data that is entered into  information that                                        screen that are not text,    a computer: for example,  contains eight bits.                                    such as pictures, icons,     from a microphone,                                                          and symbols.                 keyboard, or mouse.
219G L O S S A R Y    integer                     memory                        programming language          statement  Any number that does not    A computer chip inside a      A language that is used       The smallest complete  contain a decimal point     computer that stores data.    to give instructions to       instruction a programming  and is not written as a                                   a computer.                   language can be broken  fraction (a whole number).  module                                                      down into.                              A section of code that        random  interface                   performs a single part        A function in a               string  The means by which          of an overall program.        computer program that         A series of characters.  the user interacts with                                   allows unpredictable          Strings can contain  software or hardware.       operator                      outcomes. Useful when         numbers, letters, or                              A symbol that performs        creating games.               symbols, such as a colon.  IP address                  a specific function: for  A series of numbers that    example, “+” (addition)       run                           syntax  makes up a computer’s       or “-” (subtraction).         The command to make           The rules that determine  individual address when                                   a program start.              how a program must be  it is connected to          OS                                                          structured in order for it  the Internet.               A computer’s operating        server                        to work properly.                              system (OS) provides the      A computer that stores files  library                     basis for other programs      accessible via a network.     trojan  A collection of functions   to run, and connects                                        A piece of malware that  that can be reused in       them to hardware.             single-step                   pretends to be another  other projects.                                           A way of making a             piece of software to                              output                        computer program run          trick the user.  loop                        Data that is produced by      one step at a time, to  Part of a program that      a computer program and        check that each step is       tuple  repeats itself (to prevent  viewed by the user.           working properly.             A list of items separated by  the need for the same                                                                   commas and surrounded  piece of code to be typed   port                          socket                        by brackets.  out multiple times).        A series of numbers           The combination of an                              used by a computer as         IP address and a port,        Unicode  machine code                the “address” for a           which lets programs send      A universal code used by  The basic language          specific program.             data directly to each other   computers to represent  understood by computers.                                  over the Internet.            thousands of symbols  Programming languages       processor                                                   and text characters.  must be translated into     A type of electronic chip     software  machine code before the     inside a computer that        The programs that run on      variable  processor can read them.    runs programs.                a computer and control        A named place where you                                                            how it works.                 can store information  malware                     program                                                     that can be changed.                                                            sprite  Software that is designed   A set of instructions that a  A movable object.             virus  to harm or disrupt a        computer follows in order                                   A type of malware that  computer. Malware is short  to complete a task.                                         works by multiplying  for “malicious software”.                                                               itself to spread between                                                                                          computers.
220 R E F E R E N C E    Index    Page numbers in bold refer         bits 183, 189, 218                     in strings 114                    algorithms 16, 17  to main entries.                   black-hat hackers 213                  Unicode 185                       bad programs 212–13                                     blank lines 117                     Chef 199                             essential 190–1  A                                  blocks                              circles, drawing 157, 158            experimenting with 19                                                                         circuits, computer 187, 188, 189     how they work 15  Ada 18                                colored 31                       clicking, and events 44, 66, 162     uses of 14  addition 52, 102, 112                 connecting 18                    clock pulse 188                   computers  Adobe Flash 25                        creating 72–3                    coordinates                          deconstructing 217  AI see Artificial Intelligence        defining 72, 73                     drawing with 158                  invention of 201  algorithms 16, 17, 150–1, 218         functions of 31                     and location 168                  main parts of 180–1  Allen, Paul 200                       help with 83                        and movement 166                  mini 214–15  ALU see arithmetic logic unit         with inputs 73                      in Python 157                     supercomputers 203  American Standard Code for            programming 22                      in Scratch 56–7                console games 198                                        types of 31                      COBOL 199                         consoles 14, 204     Information Interchange see     blocks palette 27, 31, 32, 35, 38,  code windows 92, 93, 106–7        containers 134, 218     ASCII                              50                                  errors in 94                   “continue” keyword 127  “and” block/operator 63, 103,      bomb disposal 203                   coders 14, 15                     “Control” blocks 31, 65, 68     118, 119                        Boole, George 186                      becoming a coder 18–19         control unit 180  AND gate 186                       Boolean expressions 62, 63, 64,        becoming a master              controls, game 174, 205  Android operating system 198,         65, 111, 118–19, 120, 218                                          costumes 40–1     207                             botnets, zombie 213                       programmer 216–17              and movement 23, 40, 41  anti-malware software 213          brackets                               famous 200–1                      random 61  antivirus programs 213                errors 94                           and games 204                     Roll the dice project 60–1  apostrophes 115                       in lists 128, 129                   think like a computer 16–17       and speech bubbles 41  Apple Mac                             in tuples 134                    coding                               switching 34, 40, 41     file management 193                using 112, 119                      clear 143                      cryptography 202     operating system 190, 207       brain, training 216                    computer programs 14–15        CSS (Cascading Style Sheets) 208     programming languages 198       branches/branching 65, 99, 100,        reading 176, 216               cursor tools 26     Python 3 on 88, 90                 120–1, 218                          what is coding? 14–19     Scratch on 25                   breaks, inserting in loops 126–7    coding clubs 82, 207              D  apps, making 206–7                 Brin, Sergei 201                    coding contests 217  Arduino 214, 215                   broadcast blocks 70–1, 77           colors                            data 218  arithmetic logic unit (ALU) 181    browser windows 210, 211               adding to shapes 159              and functions 131  arrow keys 163, 166                Bubble blaster project 164–75          changing 60, 160                  input 180  Artificial Intelligence (AI) 203,  bugs 148–9, 177, 207, 218              mixing 156                        output 181     205                             buttons                                in Python 156–7                   secret 202  ASCII 184, 218                        creating 152, 154–5                 selecting 156                     sending via Internet 194, 195  audio output 181, 215                 labelling 155                    commands                             theft 213                                        linking to events 162               Python and Scratch  B                                  bytes (B) 183, 192, 218                                               “Data” blocks 31, 50                                                                               compared 102–5              data storage  Babbage, Charles 200               C                                   commas  backgrounds/backdrop 23, 26                                                                                 in files 192–3                                     C 18, 198                              in lists 128                      memory 180, 181, 188, 189     changes to 45                   C++ 198                                in tuples 134                     in variables 50     selecting from library 33, 74   calculations 180, 181, 189          comments, adding 143              data types     switching 41                                                        comparison blocks/operators          converting 111  backpack, Scratch 82                  in Python 112                       62–3, 118–19                      mixed 111  banking 199, 202                      in Scratch 52–3                  compass 39                           spotting 111  bases 182–3                           supercomputers 203               compilers 191                        tuples and dictionaries 134–5  BASIC 199                          calling functions 104, 139, 218     components, computer 181, 217     debugging 148–9, 174, 177, 207,  battery, computer 181              cameras 215                         compression 202, 218                 218  beats 59                           canvas 157, 158                     computer circuits 187, 188, 189   decimal system 182  Berners-Lee, Tim 201               cars 14                             computer games see games          decisions  binary code/signals 15, 182–3,     characters                          computer languages see               and branches 64–5     184, 185, 195, 218                 between outputs 117                 programming languages             flowcharts 141                                        numbering in strings 115         computer programmers see             logic gates 186–7                                                                            coders                                                                         computer programs 14–15
I N D E X 221    dice simulator 155               floats 110, 218                      H                                   connection to 19  dictionaries 135                 flowcharts 141, 146                                                      programming for 208–9  direction 39                     folders 193                          hackers 213, 218                 Internet browsers 209  directories 193, 218             “for” loops 122, 124                 hardware 15, 181, 191, 218       Internet Protocol 194  directory trees 193              “forever” block 23, 31, 32, 33, 38,                                   interpreters 191  division 52, 102, 112                                                    programming 198               inverters 186  domain names 194                    39, 46, 47, 125                   hexadecimal 156, 183, 185, 218   iOS devices 198  drawing                          forever loop 46, 47, 69, 103, 125,   high-level languages 191         IP addresses 194, 195, 219                                                                        Hopper, Grace 200     on a canvas 157, 165             133                               HTML (HyperText Markup           J     with coordinates 158          Fortran 199     pens and turtles 48–9, 122,   full stops 117                          Language) 208, 209, 210       Java 18, 198                                   functions 72, 130–1, 132–3, 218                                       JavaScript 18, 198, 208, 209        152                                                             I  Drawing machine project 140–7       calling 104, 130, 139                                                 using 210–11  drums 59                            getting data back from 131        IDLE                             JPEGs 193                                      making 130                           code and shell windows 106–7  E                                   passing data to 131                  color codes 107               K                                      using and naming 143                 and errors 148  educational apps 206                and variables 138–9                  how it works 93               keyboard  electrical signals 195                                                   and installation of Python       events 44, 66, 162, 163, 211  “elif” command 121               G                                          89, 90, 91                    input function 116, 162, 163,  “else-if” command see “elif”                                             what is IDLE? 88                    180                                   gadgets 215                             working in 92–3, 209     command                       Game Boy 201                                                          keys, dictionaries 135  emails                           game engines 205                     “if” block/command 64, 120       kilobytes (KB) 183, 192                                   game logic 205                       “if-elif-else” command 121     spam 213                      games 14, 204–5                      “if-else” command 120            L     websites 198, 208                                                  “if-then” block/command 64, 66,  encryption 202, 218                 customizing 81                                                     laptops 181  “end” label 117                     improving 174                        67, 103                       latch circuits 189  errors 94–5                         in JavaScript 209                 “if-then-else” block/command     letter commands 141     finding and fixing 148–9         making with Python 177                                             level designers 204  Escape the dragon! project 32–7     for mobile devices 206               64, 65, 76, 103               libraries 219  event handlers 166, 211             online 195                        “in” operator 119  events 211, 218                     random numbers in 53              indents 98                          building your own 176     reacting to 162–3                see also projects                 index numbers 115, 128, 218         help and documentation  “Events” blocks 31, 32, 44–5     Gates, Bill 200                      infinite loops 125  EXCLUSIVE OR gate 187            gates, logic 186–7, 218              input                                  153  experimenting                    Ghost game project 96–9                                                  importing 153     with coding 19                gigabytes (GB) 189, 192                 blocks with 73                light, data transmission as     with Python 176–7             global variables 138, 139               devices 162, 180, 189            pulses of 195     with Scratch 82–3             GNU/Linux operating system 201          logic gates 186–7             Linux 88, 201                                   Google 86, 201, 217                     program 31, 100, 101, 106,    lists  F                                GPU 218                                                                  adding/deleting items 55, 105,                                   graphic designers 204                      116, 180, 218  Facebook 201                     graphical user interface             “input()” function 101, 130            128, 129, 169  false see true or false             see GUI                           insertion sort 150                  combining 129  fiberoptic cables 195            graphics 218                         installation                        commands 105  file browsers 190                   changing 160–1                                                        copying 137  files 218                           color and coordinates 156–7          Python 3 88–91                   creating 55, 105                                      effects 43, 152, 153                 Scratch 24–5                     in loops 129     compressing 202                  games 205                         instruments, musical 59             playing with 55     corruption 213                   making shapes 158–9               integers 110, 219                   putting tuples in 134     managing 193                  graphics processing unit             Integrated DeveLopment              in Python 128–9, 132–3     properties 192                   see GPU                              Environment see IDLE             in Scratch 54–5     sizes 192                     grid, x and y 56, 158                interface                           using 55, 129, 167     storing data in 192–3         GUI 154–9, 218                          GUI 154–5                        in variables 136–7  firewalls 213                                                            Scratch 26–7, 49                                                                           user 140, 146–7, 219                                                                        Internet 194–5                                                                           connecting to other                                                                                computers via 152
222 R E F E R E N C E    local variables 138, 139         mini computers 214–15                O                                    from the past 199  logic circuits 187, 188, 189     Miyamoto, Shigeru 201                                                     and interpreters 191  logic errors 148                 mobile phones 14, 204, 215           Objective-C 198                      learning new 217  logic gates 186–7, 188, 189                                           Ook 199                              popular 198  logical operators 118–19            apps 206–7                        open source movement 201             Python and Scratch commands  LOGO 49                          modules 219                          operating systems (OS) 25,  “Looks” blocks 31, 40, 42–3                                                                                   compared 102–5  loop blocks 46                      importing 153                        88–91, 92, 190–1, 207, 219        text-based 86  loops 100, 103, 219                 Standard Library 152              operators 219                        weird 199                                   Monkey mayhem project 74–81                                            programs see computer     complex 68–9                  motherboard 181                         blocks 31, 52, 53                 programs     with conditions 104           “Motion” blocks 31, 32, 33, 34, 36,     logical 118–19                 projects 11, 23     escaping 126–7                   38–9, 57, 75                      “or” block/operator 63, 103, 118     Bubble blaster 164–75     “for” 122, 124                motion detector, webcam 45           OR gate 187                          Drawing machine 140–7     forever 46, 47, 69, 103, 125  mouse                                OS see operating systems             Escape the dragon! 32–7     in JavaScript 211                control 25                        output                               Ghost game 96–9     lists in 129                     events 162, 211                      and branching 120–1               Monkey mayhem 74–81     main 99, 168, 169, 171           input function 180, 189              devices 180, 181, 189             remixing existing 82     nested 69, 123                mouse-pointer                           logic gates 186–7                 Roll the dice 60–1     in Python 122–7, 133             coordinates 56                       program 31, 92, 100, 101,         Silly sentences 132–3     in Scratch 46–7, 68–9            following 69                                                        PS4 204     simple 46–7                      pointing toward 32, 33, 36              106, 108, 116–17, 180–1     pseudocode 143, 144, 147     skipping 124, 127             movement                                                               Pygame 153, 177     stopping 125                     coordinates 57                    P                                 Python 19, 83, 84–177     variable 123                     and costumes 23, 40, 41                                                algorithms 150–1     while 124–5                      with keys 66, 163, 166            packets 194, 195                     ASCII in 184  Lovelace, Ada 200                   and “Sensing” blocks 66, 67       Page, Larry 201                      Booleans 111  low-level languages 191             sprites 22, 23, 38–9, 57          painting area 60, 61                 branching 120–1                                   Mpegs 193                            passwords, theft of 213              Bubble blaster project 164–75  M                                multiplication 52, 102, 112          paths 193                            bugs and debugging 148–9                                   music                                “Pen” blocks 31, 48–9, 87, 107       code structure 98–9  Mac see Apple Mac                   adding 37, 79                     Peters, Tim 151                      color and coordinates 156–7  Mac OS X 190                        files 192, 193, 202               photograph files 193                 color codes 107  machine code 188, 191, 219          making your own 59                Pi 214                               different versions of 177  Malbolge 199                        playing 59                        pictures, files 192, 193             Drawing machine project  malware 212–13, 219                 tempo 59                          Piet 199  Math module 152                  mutable/immutable objects            pilots 205                              140–7  math                                129                               Pixar 86                             errors 94–5                                                                        pixels 156                           escaping loops 126–7     in Python 102, 112–13         N                                    player’s name 50                     functions 130–1, 132–3     in Scratch 52–3, 102                                               PNGs 193                             Ghost game project 96–9  MATLAB 18                        name errors 95                       pop-up boxes/windows 146,            harder commands 104–5  medicine 203                     NASA 86                                                                   input and output 116–17  megabytes (MB) 183, 189, 192     negative numbers 56, 57                 209, 210                          installing 88–91  memory 180–1, 188–9, 190,        nested loops 47, 69, 123             ports 195, 219                       introducing IDLE 92–3     192, 219                      network adaptors 181, 195            position                             libraries 152–3  messages                         networks, computer 152,                                                   lists 128–9, 132–3     reacting to 70                                                        coordinates 56–7                  lists in variables 136–7     sending and receiving 70         194, 218                             random 43, 57                     loops in 122–7, 133  microphones, and events 44, 45   nibbles 183                          “print()” function 87, 101, 102,     making decisions 118–19  Microsoft 200                    NOT gate 186                            108, 109, 116, 117, 130           making games with 177  Microsoft Windows                notes, musical 59                    printers 181                         making shapes 158–9     file management 193           numbers                              processors 100, 101, 180–1,          making windows 154–5     operating system 190, 207                                             188–9, 190, 203, 219              math in 112–13     Python 3 on 88, 89               binary and bases 182–3            program flow 100–1                   numbers in 110     Scratch on 25                    comparing 62, 118                 programming languages 15, 18,        print in 87  millennium bug 199                  data types in Python 110             19, 22, 49, 83, 198–9, 219        program flow 100–1                                      random 53, 104, 113, 152, 155        conversion into machine code      reacting to events 162–3                                                                                188                                                                           first 200
I N D E X 223       saving work 88                     home-built 215                     simple commands 102–3          sound designers 204     and Scratch 87, 101, 102–5,     Roll the dice project 60–1            simple loops 46–7              sound library 79                                     rotation                              software 24                    sounds 22, 23        124, 125                                                           special effects 42–3     scripts 101                        styles 38                          sprites 28–9                      adding to program 58–9, 79     shell and code windows 92,         tools 61                           strings and lists 54–5            detectors 45                                     routers 194, 195                      true or false 62–3                in games 205        93, 106–7                    Ruby 18                               typical programs 23               playing 58     shortcuts 171                   running                               understanding 22                  selecting from library 37, 58     Silly sentences project 132–3      programs 23, 102, 106              variables 50–1, 108               volume control 58     simple commands 102–3              scripts 30                         versions of 25                 spam 213     sorting in 151                  runtime errors 148                    and webcams 45                 speakers 181     strings in 110, 114–15, 117                                           website 24, 82                 speech bubbles 22, 28, 87, 101     tuples and dictionaries 134–5   S                                     what is Scratch? 18, 22–3         adding 41, 161     turtle graphics 87                                                 screens 181                          conversations 71     types of data 110–11            saving your work 11                scripts 22, 23                    speed, setting 51, 77     Unicode in 185                     in Python 88, 93, 106, 107         building 27                    “split()” function 144     variables 99, 101, 108–9, 116      in Scratch 24, 25, 33              and colored blocks 30–1        sprites 22, 23, 28–9, 39, 219     variables and functions 138–9                                         flow of 30                        adding graphic effects 43     website 89                      saying things (in Python) 161         pausing 69                        adding more 76–7, 80     what is Python? 19, 86–7        score 50, 79, 99, 172–3               in Python 101                     adding sounds 58–9     what next? 176–7                scoreboards 172                       repeating 68                      changing size 43     while loops 124–5               Scratch 20–83                         running 30                        changing time or speed 35, 51                                                                           in Scratch 30–1, 101              coordinates 56–7  Q                                     account 24                         and sprites 28                    collisions 67                                        adding sounds 58–9, 79             stopping 30, 68                   communication between  questions                             backpack 82                        testing 30     asking 54                          blocks 30–1, 72–3               scripts area 27                         70–1     combining 63                       coordinates 56–7                scripts tab 27                       controlling 31, 66     true or false 62–3                 complex loops 68–9              scriptwriters 204                    copying or deleting 29                                        costumes 40–1                   SD cards 215                         creating and editing 29, 34, 36  quote marks                           creating blocks 72–3            secret data 202                      designing your own 39     errors 94                          decisions and branches 64–5     selection sort 151                   direction 39     in lists 128                       Escape the dragon! project      “Sensing” blocks 31, 34, 36, 51,     and events 44–5     in strings 110, 114, 116                                              65, 66–7, 75                      hiding and showing 42                                           32–7                         separators 117                       in the interface 28  R                                     events 44–5                     servers 219                          movement 22, 23, 38–9, 57,                                        experimenting with 82–3         shapes  radio waves 195                       harder commands 104–5              adding color 159                     66–7  RAM 189                               help menu 83                       drawing 140                       naming 29  “randint()” function 98, 99, 101,     hide and seek 42–3                 making 158–9                      pen tools 48–9                                        installing and launching 24–5      moving 160                        renaming 29     104, 113, 130, 153, 155            interface 26–7, 49                 naming 160                        rotation styles 38  Random Access Memory                  lists 55                        shell windows 92, 93, 106–7, 116     and scripts 28                                        make some noise 58–9               errors in 95                      selecting from library 34, 36,     see RAM                            making things move 38–9         silicon chips 188, 189  Random module 152, 153, 157           math in 52–3                    Silly sentences project 132–3           39, 75, 76  random numbers 53, 104, 113,          menu and tools 26               skipping, in loops 127               and “Sensing” blocks 66–7                                        and microphones 45              slicing 115                          sprite list 27     152, 155                           Monkey mayhem project           smartphones 206                      turtle graphics 49  random positions 43, 57                                               social apps 206                      and variables 35, 50–1  Raspberry Pi 25, 214                     74–81                        Socket module 152                    what they can do 28  reacting to events 162–3              pens and turtles 48–9, 87       sockets 195, 219                  square roots 53  readable code 133                     and Python 87, 102–5, 124, 125  software 14, 15, 219              stage 23, 25, 27  remainders 53                         and Python’s Ghost game 101     sorting algorithms 150–1          Standard Library modules 152  repeat loops 46, 122, 211             Roll the dice project 60–1      “Sound” blocks 31, 58–9           stop button 30  “repeat until” block 68, 76, 77,      scripts and colored blocks                                        stopping programs 102                                                                                                          strategy games 205     78, 124                               30–1, 101                                                      strings 219  rewriting code 217                    sending messages 70–1                                                adding 114  robots 16, 203, 217                   sensing and detecting 66–7
224 R E F E R E N C E       assigning 108                 turtle graphics 49, 87, 105, 107          read-only 51                    X     comparing 63, 118, 119           commands 105, 145                      results in 52     creating 114                     Drawing machine project                in Scratch 50–1, 108            x and y coordinates 56, 57, 157,     joining 105                         140–7                               splitting tuples into 134          158, 166, 168     length of 114                    and loops 122                          strings in 114     operators 119                                                           using 51, 109                   Xbox One 204     in Python 110, 114–15, 117    Turtle module 152, 176                 video files 192, 193     in Scratch 54–5                                                      video games 204–5                  Y     separating 117                U                                         writing 153  subprograms see functions                                               viruses 212–13, 219                Yokoi, Gunpei 201  subtraction 52, 102, 112         Ubuntu                                 visual output 181  supercomputers 203                  file management 193                 volume control 58                  Z  surgeons 205                        Python 3 on 88, 91                  von Neumann, John 180  symbols, choice of 143              Scratch on 25                                                          zombie botnets 213  syntax 219                                                              W                                  Zuckerberg, Mark 201     errors 94, 148                Unicode 185, 219                                   upper/lower case 94                    washing machines 14  T                                USBs 215                               watches 206                                   user interface 140, 146–7, 219         wearable technology 206  tablets 25, 206                                                         weather forecasting 199, 203,  tabs 26, 27                      V  teleporting 43                                                             206, 215  television 215                   values                                 web browsers 86, 195, 198  tempo 59                            assigning to variables 108,         web servers 198  terabytes (TB) 192                     109, 113, 118, 136               webcams, and events 44, 45  testers, game 204                   changing 136                        websites  text editors 88                     in dictionaries 135  text files 193                      and functions 131                      construction 208–9  text messages 14                                                           email 198, 208  text-based programming           variables 35, 219                         interactive 198, 208, 210, 211                                      assigning a value to 108, 109,         Python 89     languages 86                        113, 118, 136                       Scratch 24, 82  time limit 172–3                    changing contents of 109            while loops 124–5  Time module 152                     comparing 62, 63, 118               white-hat hackers 213  Tkinter module 152, 154–5, 156,     creating 50, 54, 77, 102, 108       Wikipedia 201                                      deleting 51                         Windows see Microsoft Windows     157, 158, 159, 162, 165, 176     and functions 138–9                 windows  transistors 188                     global 138, 139                        code and shell 92, 93, 106–7  travel apps 206                     lists in 136–7                         making 152, 154–5, 165  Trojans 212, 213, 219               local 138, 139                      word processing 86  true or false 62–3, 64, 111,        loop variables 123                  words, comparing 63                                      naming 50, 109, 143                 World Wide Web 201     118–21, 125                      in Python 99, 101, 108–9, 116,      worms 212, 213  tuples 134, 219                        138–9  Turing, Alan 200    Acknowledgments    DORLING KINDERSLEY would like to thank: Max Albert for technical        Scratch is developed by the Lifelong Kindergarten Group at MIT  assistance on the US edition; Vicky Short, Mandy Earey, Sandra Perry,   Media Lab. See http://scratch.mit.edu  and Tannishtha Chakraborty for their design assistance; Olivia  Stanford for her editorial assistance; Caroline Hunt for proofreading;  Python is copyright © 2001–2013 Python Software Foundation; All  Helen Peters for the index; and Adam Brackenbury for creative           Rights Reserved.  technical support.    DORLING KINDERSLEY INDIA would like to thank: Kanika Mittal for  design assistance; Pawan Kumar for pre-production assistance; and  Saloni Singh for editorial management of the jackets team.
                                
                                
                                Search
                            
                            Read the Text Version
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
 
                    