Turtle Power. Introduction: Python. In this project, you ll learn how to use a turtle to draw awesome shapes and patterns. Activity Checklist



Similar documents
STEP 0: OPEN UP THE PYTHON EDITOR. If python is on your computer already, it's time to get started. On Windows, find IDLE in the start menu.

MSW LOGO 2. MSW LOGO is a programming language that lets you store a series of instructions on the computer.

Week 2 Practical Objects and Turtles

Chapter 2. Making Shapes

Fractions as Parts of a Group

GETTING STARTED. number of sides. draw a line. turn BIGGER OR SMALLER. change this number SQUARE TRIANGLE. these numbers have changed

Python Loops and String Manipulation

Tessellating with Regular Polygons

Digital Marketing EasyEditor Guide Dynamic

Programming in Access VBA

Hello. What s inside? Ready to build a website?

Getting Started with WebSite Tonight

Hello. What s inside? Ready to build a website?

Fruit Machine. Level. Activity Checklist Follow these INSTRUCTIONS one by one. Test Your Project Click on the green flag to TEST your code

Introduction to SketchUp

Advanced Programming with LEGO NXT MindStorms

Microsoft Small Basic. An introduction to Programming

Publisher 2010 Cheat Sheet

Getting Started in Tinkercad

Glow-in-the-Dark Geometry

Goal: Practice writing pseudocode and understand how pseudocode translates to real code.

SMARTstuff. The first rule for using an interactive whiteboard is very simple and of the utmost importance: Have faith in yourself you can do this!

Internet basics 2.2 Staying safe online. Beginner s guide to. Basics

Which shapes make floor tilings?

Fireworks CS4 Tutorial Part 1: Intro

LESSON 7: IMPORTING AND VECTORIZING A BITMAP IMAGE

How To Proofread

Grade 7/8 Math Circles November 3/4, M.C. Escher and Tessellations

DOING MORE WITH WORD: MICROSOFT OFFICE 2010

Microsoft Word defaults to left justified (aligned) paragraphs. This means that new lines automatically line up with the left margin.

The Basics of Robot Mazes Teacher Notes

Grade 8 Mathematics Geometry: Lesson 2

Fish Chomp. Level. Activity Checklist Follow these INSTRUCTIONS one by one. Test Your Project Click on the green flag to TEST your code

Photoshop- Image Editing

Class Registration 101

Target To know the properties of a rectangle

Grade 7/8 Math Circles Sequences and Series

PUZZLES AND GAMES THE TOOTHPICK WAY

angle attribute Figure 1 4 right angles opposite sides parallel Lesson 14 5 Lesson 14 4 Vocab

The GED math test gives you a page of math formulas that

Logo for Kids: An Introduction. by Bob DuCharme

From the list of Cooperative Extension applications, choose Contacts Extension Contact Management System.

You can start to fill in your profile section in UCAS Progress as soon as you have received your username and password.

Section 1.5 Exponents, Square Roots, and the Order of Operations

3. Locate the different selections of Styles from the Home Tab, Styles Group

Whack-a-Witch. Level. Activity Checklist Follow these INSTRUCTIONS one by one. Test Your Project Click on the green flag to TEST your code

PowerPoint 2013: Basic Skills

Beginner s Guide to MailChimp

family games Taking the kids swimming is a great way of making sure they re moving around and having fun. And to help you get them into

3D Drawing. Single Point Perspective with Diminishing Spaces

Microsoft PowerPoint Exercises 4

Tutorial 1: The Freehand Tools

Sage Accountants Business Cloud EasyEditor Quick Start Guide

Microsoft Outlook Introduction

SPRING UNIT 14. second half. Line symmetry and reflection. Measuring angles. Naming and estimating angles. Drawing angles

Page 18. Using Software To Make More Money With Surveys. Visit us on the web at:

Grade 4 Mathematics Patterns, Relations, and Functions: Lesson 1

Google SketchUp Design Exercise 3

PEMBINA TRAILS SCHOOL DIVISION. Information Technology Department. Inspiration 7.0

Hexagonal Pyramid in Google SketchUp

Introduction to Google SketchUp (Mac Version)

CSC 120: Computer Science for the Sciences (R section)

GAP CLOSING. 2D Measurement. Intermediate / Senior Student Book

UNIT H1 Angles and Symmetry Activities

Published : License : None. INTRODUCTION 1. Learning with Turtle Art

Building Qualtrics Surveys for EFS & ALC Course Evaluations: Step by Step Instructions

SolidWorks Tutorial 4 CANDLESTICK

Basic Formulas in Excel. Why use cell names in formulas instead of actual numbers?

Greetings Card. Projects 1

Three-Dimensional Figures or Space Figures. Rectangular Prism Cylinder Cone Sphere. Two-Dimensional Figures or Plane Figures

SLA Online User Guide

MATHEMATICS Y3 Using and applying mathematics 3810 Solve mathematical puzzles and investigate. Equipment MathSphere

Basic AutoSketch Manual

CREATING YOUR OWN PROFESSIONAL WEBSITE

Illustrator - bezier pen, advanced techniques

Samsung Xchange for Mac User Guide. Winter 2013 v2.3

Computing and Communications Services (CCS) - LimeSurvey Quick Start Guide Version 2.2 1

How to make internal links in a Word document

Shapes & Designs Notes

Why Your Business Needs a Website: Ten Reasons. Contact Us: Info@intensiveonlinemarketers.com

Grade 3 Core Standard III Assessment

EARLY CHILDHOOD LITERACY AND NUMERACY BUILDING GOOD PRACTICE MARILYN FLEER AND BRIDIE RABAN

In Person Mobile Website Selling Script In Person Cold Call or Appointment

Exploring Tangrams. Goal. You will need scissors and a ruler. At-Home Help. 1. Trace and cut out the 7 tans.

The Windows Command Prompt: Simpler and More Useful Than You Think

Using VLOOKUP to Combine Data in Microsoft Excel

Smart Board Notebook Software A guide for new Smart Board users

Python for Rookies. Example Examination Paper

Learn How to Revise 1

How To Create Your Own Profitable Banners In Minutes!

How to Create a Campaign in AdWords Editor

Avatar: Appearance Changing Your Shape Introduction Instruction Practice LEVEL: 1 MODULE: AVATAR: APPEARANCE MISSION 2

Draw pie charts in Excel

Microsoft PowerPoint 2010 Templates and Slide Masters (Level 3)

SPREADSHEETS. TIP! Whenever you get some new data, save it under a new name! Then if you mess things up, you can always go back to the original.

Estimating Angle Measures

Templates and Slide Masters in PowerPoint 2003

HOW TO ORGANIZE PICTURES

It starts like this...

Transcription:

Python 1 Turtle Power All Code Clubs must be registered. By registering your club we can measure our impact, and we can continue to provide free resources that help children learn to code. You can register your club at codeclubworld.org. Introduction: In this project, you ll learn how to use a turtle to draw awesome shapes and patterns. Activity Checklist Test your Project Save your Project Follow these INSTRUCTIONS one by one Click on the green flag to TEST your code Make sure to SAVE your work now 1

Step 1: Hello, turtle! We re going to have some fun programming turtles. A turtle is a tiny robot that draws on your screen, and can be controlled using Python commands. Activity Checklist Let s make a turtle move around the screen, by running this short Python program: speed(5) right(90) The turtle has a pen attached, and draws a line as it moves around the screen. Here s what the program does: tells Python that you want to use the turtle library, a collection of code you can use to draw on the screen. The * means import everything. 2

makes the drawing robot look like a turtle. As well as turtle, you can also use arrow, circle, square, triangle or classic. speed(5) tells the turtle how fast to draw. You can use a number between 1 and 11. 11 is the fastest, 1 is the slowest. and backward(100) tells the turtle to move forward or backward 100 pixels. left(45) and right(90) turn the turtle left or right by a number of degrees. Here are some examples: tells Python that we ve finished programming the turtle. What s your favourite colour? To make your drawings more interesting, you can also change the colour and the size of the pen drawing the line. Here s a simple example to try: 3

speed(8) color("purple") pensize(7) right(90) left(90) forward(50) color("orange") pensize(3) penup() forward(50) pendown() forward(50) The code above contains a couple of new commands: color("purple") turns the turtle and the line purple. Notice the American spelling of the word colour, which doesn t have a u in it. You can also specify colours in hex, like you did in CSS. Instead of using pencolor("red") you could use pencolor("#ff0000"). penup() lifts the pen from the screen, and pendown() lowers it again. This means that you can move the turtle without leaving a trail! 4

Save Your Project Challenge: Drawing shapes Can you use the turtle instructions above to draw: A square? A triangle? Can you draw a house? What else can you draw? Save Your Project Step 2: Repeating yourself When drawing a square and a triangle, your program repeated the same commands over and over again. Let s get Python to repeat them for us! Activity Checklist Open up a new file, and run the following program: speed(11) for count in range(4): right(90) This program uses a for loop. You can use a for loop in Python whenever you want to repeat some code a set number 5

of times. In the program above, the commands and right(90) are repeated 4 times, drawing a square. Turning 90 degrees for each corner means we turn 360 degrees in total. Just like with an if statement, you should use the Tab key to indent the code that you want to repeat. Try changing the code, so that the line is indented but the line right(50) isn t, like this: speed(11) for count in range(4): right(90) What happens when you run this program? Did you get a straight line? In this program, Python will repeat four times, and then turn right(90). Now that you know how to repeat commands, you can create complicated shapes and patterns really easily. Run this program: speed(11) for count in range(8): 6

right(45) This program works in the same way as the square drawing program, except that it repeats 8 times, and only turns 45 degrees for each corner. This means that the code draws an 8-sided shape (an octagon), as the corners for each of the 8 sides add up to 360 degrees (360 divided by 8 is 45). Here s another example of what can be created using a for loop. What does this program draw? speed(11) for count in range(30): forward(5) penup() forward(5) pendown() 7

Save Your Project Challenge: Loopy shapes Can you use a for loop to draw: A pentagon? (five sides) A hexagon? (six sides) Remember that the angles of all the corners always add up to 360 degrees! Can you draw a circle? You can move forward 1 pixel and turn 1 degree each time. How many times would you need to repeat these commands? Save Your Project 8

Challenge: Drawing patterns Can you use what you ve learnt to draw awesome patterns? Here s an example: speed(11) pensize(6) color("red") for count in range(36): right(100) Save Your Project 9

Challenge: Variables and loops When drawing different shapes, you had to calculate how many degrees to turn for each corner yourself. Can you use a calculation, so that the computer works this out for you? To work out the number of degrees to turn, you can divide 360 by the number of sides in the shape: sides = 4 angle = 360 / sides / is the Python symbol for divide. Notice that the answer is stored in a variable called angle, which you can then use to draw your shape: left(angle) You can then change the number stored in the sides variable and test that it works for any shape! Save Your Project 10