American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

1 PM – Intro To Python (Summer Session) – Darin

July 3 @ 1:00 pm - 3:00 pm

What We Did Today:

  1. Learnt how to use the turtle module to draw in python.
  2. Packaged our code into functions so it becomes easier for us to draw things.

Homework:

Do the homework in the file called Jul3_AdvancedTurtleDrawing and submit it into the google drive when you are finished.

Continuing the code shown below, convert the shape into a function that can be used to draw the shape at any given x and y coordinate.

# Jul3_AdvancedTurtleHW
import turtle as t
import random as r

t.bgcolor("lightblue")
t.speed("fastest")

def makeRectangle(x, y, width, height, c):
   t.penup()
   t.goto(x, y)
   t.pendown()

   t.color(c)
   t.begin_fill()

   for i in range(2):
      t.forward(width) # width
      t.right(90)
      t.forward(height) # height
      t.right(90)

   t.end_fill()

# how to make a circle
def makeCircle(x, y, radius, c):
   t.color(c)
   # moving locations
   t.penup()
   t.goto(x, y)
   t.pendown()

   t.begin_fill()
   t.circle(radius) # radius
   t.end_fill()

# transform this into a function with x and y coordinates that you can set
makeRectangle(0, 0, 200, 200, "black")
makeCircle(100, -150, 50, "red")
makeCircle(20, -50, 20, "blue")
makeCircle(170, -170, 20, "green")
makeCircle(170, -60, 20, "yellow")

def makeShape():
   # implement this

makeShape(200, 0)
makeShape(-200, -200)

Notes:

If you have any questions, you can email me at ddjapri@ayclogic.com!!

Details

Date:
July 3
Time:
1:00 pm - 3:00 pm
Event Categories:
,
Verified by MonsterInsights