Level 1: Help - IncrediCoders/Python1 GitHub Wiki

GitHubAvatar G_think

Grafika Turtle added this page on March 14, 2023


Hello! This page will help you, in case you get stuck while programming your Turtle Map (that I showed you during our car ride). Here are the different sections on this page, which are all built out to help you become a Turtle Map expert:

  1. Opening Your Files in Visual Studio - Learn how to open Turtle Map in Visual Studio Code.
  2. Play the Game - Run the complete Turtle Map program, to see what the final version looks like (after you go through the instructions).
  3. Glossary of Terms - This list goes through the my instructions I sent you, and it explains every term and idea in depth, one topic at a time, as I bring it up in the book!
  4. Advice on Writing the Code - Eventually, in the book, I ask you to write your own code. Still stuck? Well, here are some hints on how to write the code!
  5. The Final Code - After you're done, it might not work the way you expected, or it might not work the same as our version (see Play the Game). Check out my code to see what you missed! IMPORTANT: Please don't cheat yourself! Finish the game first!

1. Opening Your Files in Visual Studio

You should already have all your Level1 files loaded into Visual Studio Code. For the full instructions on how to do this, please read Load the IncrediCoders Files.

2. Play the Game

Well, Turtle Map is a program, not a game. But you can run the program to see what the finished program looks like, before you build it (or while you're building it). You can see the full instructions on how to download and run the program at Try the IncrediCoders Games.

Here are the downloads to run the Level 1 program - Turtle Map:

Here are the instructions on how to use the Level 1 program: Level 1 Instructions

3. Glossary of Terms

Each programming language talks to the computer in a different way (much like how C-3PO is the only one who can understand R2-D2). That's called the syntax, which is the set of rules that the Python programming language uses to communicate with the computer. This glossary helps explain each of the Python code statements in depth, and then we also define more general terms that will be useful to you, when learning how to write code.

Below are the key definitions for terms that we covered in Level 1. The definitions are listed in the order that you'll need to know, as I bring up each topic and idea in the book:

  1. Code: The symbols and words that you write to tell your program what to do. Your code has to follow the guidelines and rules of the coding language that you are writing in (such as Python). When you're coding your program, it means that certain combinations of these words and symbols will result in different actions on your screen.

  2. Python Language: There are many coding languages. The one you are using, Python, has its own unique set of rules and functions, in order for you to be able to run your code. We believe Python is a great first language to use, as it is a full, professional language that is easy to learn (due to its syntax and readability). It's simpler than most programming languages.

  3. Module: A module in Python is a library, which includes an object and methods. It's a set of useful statements, just like how a toolbox is full of useful tools. A library has a specific purpose, like complex math functions, or allowing you to control a turtle. For example, we use the screen and turtle objects in this level.

  4. Turtle: The turtle object is a set of methods (or commands) that tell the turtle what to do. They describe what the turtle is going to look like (the properties). For example, you can tell the turtle to move or rotate. These are commands. You can also change the color of the turtle (using turtle.color()) or the shape of the turtle (using turtle.shape()). These are properties. In this program, our turtle is green and is shaped like a turtle (rather than an arrow, which is the default shape). These are properties that we set. Together, commands and properties are called methods.

  5. Import: Importing means to load libraries (which are toolboxes full of tools) into a program. For example, we import the turtle module to load and access the turtle methods (commands and properties). After you import the turtle module, you can set the shape and color of the turtle.

  6. Screen(): This object allows you to set the title of your window ("Mapster Spacebook"), the size of your window, and your background image.

  7. Background.gif: This is the image that's on the background of your screen. You can write code to change the image itself, but your background image doesn't move. The code you run with the turtle character movements will be displayed on top of the background.

  8. TurtleMap.py File: This file loads the map that shows you Grafika's house and IncrediCoders Academy. There are a few paths you can take, to get to the school. You'll use a different path to get to the school in Challenge 1. In Challenge 2, you'll go back and forth (five times) on this map, between the house and school.

  9. init.py File: We have an init.py file for every level. We put extra code in this file that you don't need to write yourself. For Level 1, the code in the init.py file grabs the files from your folder (so your Turtle Map program can use it), like the Background.gif file.

  10. Method: Methods are built-in code so you do not have to write all the code out yourself. For example, right() in turtle.right() is a method that tells the turtle to go right. You do not have to write out all the code that makes the turtle go right, because it is already built in the right() method.

  11. turtle.shape(): This method changes the shape of your turtle character that you put in turtle.shape("turtle"). The default shape is actually an arrow. (The old Logo programming language originally made the turtle an arrow shape.) You can change the turtle shape to be any one of these (you put it in quotes in the parentheses, and replace "turtle"): "arrow", "turtle", "circle", "square", "triangle", and "classic".

  12. turtle.color(): This method changes the color of your turtle character to any color that you put in the parentheses. It will turn the turtle character to that color. Be sure to use quotes. For example, you use the code turtle.color("green") to change the turtle's color to green.

  13. turtle.penup() and turtle.pendown(): turtle.penup() lifts the turtle off of the screen. That way, when it is moved, it does not draw a line from its current location to wherever it is being moved to. turtle.pendown() puts the turtle back on the screen. Then, when the turtle is moved, it draws a line from its current location to wherever it is being moved to.

  14. Syntax: Syntax is the correct way to write code--just like proper spelling and grammar is the correct way to write English. If your syntax is correct, the code you write will be read by the computer, and your instructions will be executed (your code runs like expected). However, if the syntax does not match exactly as the Python language expects it, then the program may not execute your code in the way that you wanted. You might get errors that you've got to fix.

  15. X and Y Coordinates: X and Y coordinates are the directions that you can move the turtle. Y coordinates move up (a positive Y coordinate number) and down (a negative number). Likewise, X coordinates move left (a negative X coordinate number) and to the right (a positive number). The X and Y coordinates are displayed on the X and Y axis, like this:

  16. setx() and sety(): The method setx() represents the position of the turtle to the left and right. The method sety() represents the up and down position of the turtle. Think of it like a graph with an X and Y axis, where X is the horizontal position and Y is the vertical position. Or, like on a map of the world, where X is latitude and Y is longitude.

  17. F5: This is a button at the top of your keyboard, and when you press it, it will run your code! (You might need to hold down or toggle your Function key. For more ways to run your code, see Run Your Program.

  18. Comment: Hashtags (the # symbol) before a line of code will turn that line into a comment. A comment will not run when the program is executed. You can comment out some lines of code to test individual pieces of the program to see if they work, and then you can find where your problems are. For example, this comment in our TurtleMap.py file, won't run (it just tells us what the next new lines of code do):

    #Creates our screen
  19. Run the Code When I say to run the code, I mean to press F5 (like I mentioned on item #17 above). This runs the code.

  20. Important Methods:

    • turtle.right(): Moves the turtle to the right.
    • turtle.left(): Moves the turtle to the left.
    • turtle.forward(): Moves the turtle forward.
    • turtle.penup(): Picks up the turtle from the map. You cannot draw with the turtle, when the pen is up.
    • turtle.pendown(): Sets the turtle back down on the map, allowing you to draw with it again.
    • setx(): The location of the turtle on the x-axis.
    • sety(): The location of the turtle on the y-axis.
  21. Positive Number: This is any number that is greater than 0. Your turtle faces right by default. When talking about direction, giving your turtle a positive amount of steps means the turtle will move to the right.

  22. Negative Number: This is any number that is less than 0. When talking about direction, giving your turtle a negative amount of steps means the turtle will move to the left.

  23. Forward: This is a method for the turtle character that tells it to move a certain amount of steps upwards on the y-axis.

  24. Left: This is a method for the turtle character that tells it to move a certain amount of steps to the left on the x-axis.

  25. Right: This is a method for the turtle character that tells it to move a certain amount of steps to the right on the x-axis.

4. Advice on Writing the Code

My instructions got a little trickier as we went through Level 1 in the book. Eventually, I asked you to write your own code. This section gives you some hints on how to write your code!

  1. Turn to its left: You want to think about what method, from the imported turtle module, that you want to use (.left(), .right(), .forward(), etc.). Next, think about what turning to the left means. What is the number that you put in the parentheses, for the method that you used in the first part?

  2. Go forward 490 steps: Now, you want to again think about what method, from the imported turtle module, that you want to use (.left(), .right(), .forward(), etc.). Next, you are given how many steps the turtle character should go. Refer back to the first movement (on Line 23) and where you had put the "510" to get the turtle character to move forward.

  3. Turn to its right: Refer back to the first movement for more information (#1. Turn to its left). For the first part, you want to find the turtle method that's the opposite of what you did for the first movement. (You want the turtle to turn to the right instead of the left.) Then, put the number in the parentheses that will make the turtle turn to its right. (We're using right turns, which are 90 degrees.)

  4. Go forward the last 250 steps, to get to the school!: Refer back to the second movement (#2. Go forward 490 steps). This code will be the same as that movement, except for one change. Think about what change to the code will make the turtle character move 250 steps (instead of 490 steps).

Congratulations! You have successfully mapped our route to IncrediCoders Academy!

5. The Final Code

I included a solution file for Level 1: Turtle Map. This file has all the code filled in, so if you run into any issues with your code (for example, if it doesn't compile/run, or if something isn't working correctly in your program), then you can take a look at the final code file to see what you did differently:

IMPORTANT: Please don't cheat yourself! Finish the game first!

Next Steps

Next, you can take on the two extra challenges to add to your Turtle Map program and learn more! When you're done, you can move on to Level 2, the Class Introductions program!

Take the Challenges!

  1. Challenge 1: Map an alternate route to IncrediCoders Academy. This time, you'll cross the bridge, over the lake. Be sure to stay on the road!

  2. Challenge 2: Use loops to go back and forth between my house and the school, five times. (Paul's father, Monty, has to keep going back because Paul keeps forgetting his school supplies.)

More Level 1 Resources

In addition to this Help page and the instructions for our Level 1 challenges, we also have Online Articles, a Learning Quiz, an Unplugged Activity, and a Rewards article:

  • Level 1: Online Articles - I made you a list of different web pages I found, which will help you learn more about creating Turtle Graphics.

  • Level 1: Learning Quiz - I wrote some questions in case you want to quiz yourself about what you learned. Or you can teach others and quiz them!

  • Level 1: Unplugged Activity - I wrote this page with more details than what you saw in the book. In this game, you'll have one person act as the Turtle, and one person is the Programmer!

  • Level 1: Rewards - If you completed the Turtle Map project that we talked about in the car, then I set up this page to be your reward. You can see some illustrations of me and learn more about who I am! You'll also find the Turtle Award digital download, to show off your accomplishment!

Level 2

After you're completely done with Level 1 (did you do the challenges?), then it's time to move on to Level 2! While you read through Level 2 in your book, you can check out the resources from Mrs. Scratcher, as she teaches you how to build the Class Discussion program:

I hope you had fun learning about Turtle Graphics! After all, I was named after it!

-- Grafika Turtle

⚠️ **GitHub.com Fallback** ⚠️