ebook img

Coding With Python (Ready, Set, Code!) PDF

36 Pages·2019·8.071 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Coding With Python (Ready, Set, Code!)

READY, SET, CODE! CODING with Python ÁLVARO SCRIVANO This Page This Page Left Blank Left Blank Intentionally Intentionally READY, SET, CODE! CODING with Python ® Álvaro Scrivano Illustrated by Sue Downing Lerner Publications Minneapolis First American edition published in 2019 by Lerner Publishing Group, Inc. First published in Great Britain in 2018 by Wayland Copyright © Hodder and Stoughton, 2018 All rights reserved. Editor: Hayley Fairhead Design and illustrations: Collaborate All rights reserved. International copyright secured. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means—electronic, mechanical, photocopying, recording, or otherwise—without the prior written permission of Lerner Publishing Group, Inc., except for the inclusion of brief quotations in an acknowledged review. Lerner Publications Company A division of Lerner Publishing Group, Inc. 241 First Avenue North Minneapolis, MN 55401 USA For reading levels and more information, look up this title at www.lernerbooks.com. Main body text set in Frutiger LT Pro 45 Light. Typeface provided by Linotype AG. Library of Congress Cataloging-in-Publication Data The Cataloging-in-Publication Data for Coding with Python is on file at the Library of Congress. ISBN 978-1-5415-3876-4 (lib. bdg.) ISBN 978-1-5415-4667-7 (pbk.) ISBN 978-1-5415-4303-4 (eb pdf) Manufactured in the United States of America 1-45059-35886-7/25/2018 “Python” is a registered trademark of the Python Software Foundation, used by Hodder & Stoughton Limited with permission from the Foundation. Contents What Is Python? ........................................................4 Project 1: Turtle Talk .................................................6 Project 2: Argentina ................................................12 Project 3: Poppy Flower ..........................................18 Project 4: The Caterpillar .........................................24 Glossary ...................................................................30 Further Information .................................................31 Index .......................................................................32 What Is Python? A programming language is a particular way to talk to a computer. It is a set of instructions that you give the computer to use. Python is a typed programming language that allows you to create animations, graphics, and games. One of the advantages of Python is that you can get things done with less code than many other programming languages. Many famous organizations such as Google, YouTube, NASA, and Yahoo use Python. It has been used to produce the special effects for the Harry Potter and Pirates of the Caribbean films. Trinket All the projects in this book will be done using Trinket Blocks to create and run Python projects. This means you will not need to type the code; you can just drag, drop, and snap the coding blocks together! ! Note to parents To use Trinket, go to: https://trinket.io/. Trinket allows your child to create and run Python projects in a web browser, on your desktop, or on an iPad. In this book, the instructions assume the user is working on a desktop. There is no software to install. Children will be able to see their Python code and its output side-by-side. Children can also save their code online or share it with others with a link. Trinket Blocks is a free Trinket feature. 4 Creating Trinket accounts Parental permission is required to create accounts for children under 13. It is recommended that a Trinket account be created by a parent or responsible adult. Trinket can be used without downloading plug-ins or installing software. For your child to be able to save and share his or her projects, you will have to sign up and create a username and a password. Trinket Click here to view These are the main features you will find your Python when you open a new Trinket Blocks project: Click here program as Save your to run your text. work here. program. Menu Project title Coding block You will drop the blocks for your Drag blocks Your program will menus program onto this white canvas. here to run here. delete them. Be share aware Usernames and passwords are personal information and, just like your toothbrush, YOU DO NOT SHARE THEM WITH ANYBODY! 5 TURTLE TALK GET YOUR TURTLES CHATTING! READY Did you know? Turtles have been on Earth since In this project, you will the time of the use Python to create an dinosaurs—over animation of two turtles 200 million talking. Turtles are used years ago! in Python to show you the position of your program on the canvas. 1 GETTING STARTED Go to Trinket: https://trinket.io/ and log in. Type in your username and password. 6 SET Now you’ve opened Trinket, it’s time to begin a new program. You will see the You will drop the blocks 2 OPEN A NEW TRINKET following window. for your program in this Click on Click on Turtle. white canvas. and you will see the following drop-down menu. Click on Blocks. Did you know? The following Both tortoises and turtles menu will open up are reptiles. Both lay eggs on the right when and have hard, bony shells. you click on Turtle. Tortoises have flatter backs Drag the than turtles and they live on block to the white land in deserts, grasslands, canvas. You are and forests. Turtles have now ready to code. webbed feet for swimming and live in rivers, lakes, or oceans. 7 Did you know? Turtles have a hard shell that protects them like a shield. This upper shell is called a carapace. Turtles also have a lower shell called a plastron. Many turtle species can hide their heads inside their shells when attacked by predators. CODE! If you select the wrong block, you can delete it by returning Now you’re ready to start it to the blocks programming your turtles. section on the left or dragging and dropping it in the bin in the bottom right- hand corner. 3 WRITE IN PYTHON Add the following block from the Turtle menu and type: “Hello! What are you doing?” inside the quotes. Your program should look like this: Press to test your program. You should see your message disappearing off the right side of the screen, with a turtle overlapping the first word. 8

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.