Making with Code

Welcome to Making with Code! #

We’re glad you’re here! yay πŸ˜„

πŸ‘Ύ πŸ’¬ FYI

You will see πŸ’» throughout each lab.

This means that you need do something that involves writing code or using your Terminal. You can use these like little action items during labs.


[0] Your First Turtle Drawing #

πŸ’» Go to: bit.ly/day1_cs9. Experiment with turtle commands below. Can you figure out how to:

  • Change the color
  • Change the pen size
  • Draw a triangle
  • Draw a hexagon
  • Draw a circle
  • Fill a drawing with color

Turtle Commands #

  • 🌈 Explore color options here
FunctionInputExample UseExplanation
forwardamountforward(100)Moves the turtle forward by the specified amount
backwardamountbackward(100)Moves the turtle backward by the specified amount
rightangle in degreesright(45)Turns the turtle clockwise by the specified angle
leftangle in degressleft(45)Turns the turtle counter clockwise by the specified angle
colorcolornamecolor('red')Sets the color for drawing. Use “red”, “black”, etc. Here’s a list of all the colors.
speednumber from 0-10speed(0)Determines the speed at which the turtle moves around the window. 1 for slowest, 3 for normal speed, 10 for fast, 0 for fastest.
pendownNonependown()Puts down the turtle/pen so that it draws when it moves
penupNonepenup()Picks up the turtle/pen so that it doesn’t draw when it moves
pensizewidthpensize(4)Sets the width of the pen for drawing
setheadinganglesetheading(90)Sets the pen to the 0th degree
circlesizecircle(10)Sets the radius of the circle
gotox, ygoto(90,0)Moves turtle to a given coordinate
begin_fillNonebegin_fill()Marks the start of the color fill
end_fillNoneend_fill()Marks the end of the color fill
fillcolorcolornamefillcolor('purple')Sets the color of the fill

Error and Bugs #

While trying this out, you may come across errors or bugs, do not fear! Write the issue down, and we can talk about it during class. Try to figure out whether your bug is a:

Programmatic error (which happens when the program does something different than what you wanted. Remember that this happened when we set the angle to the wrong number)
Syntax error (which happens when the program crashes because the program cannot be understood by the computer. Remember that this happened when we forgot a parentheses).