American Young Coder

AYC logo
Loading Events

« All Events

  • This event has passed.

7 PM – Intro To Python – Darin

July 30 @ 7:00 pm - 8:00 pm

What We Did Today:

  1. Finished a robot drawing using python and geometry
  2. Learnt how to use different shapes to form a function for a drawing

Homework:

  1. Draw something with at least 4 rectangles WITHOUT a function
  2. make sure the first rectangle is at (0, 0) for starting point
  3. Transform this drawing into a function, as shown above.
  4. The trick is to replace the first rectangles starting point with (x, y)
  5. and for every other rectangle, you add the x and y in front of it for starting point

So something like this:

# head
makeRectangle(0, 0, "red", 80, 50)
# eyes
makeRectangle(25, -10, "white", 30, 10)
makeRectangle(30, -15, "black", 5, 5)
makeRectangle(40, -15, "black", 5, 5)
# mouth
makeRectangle(20, -35, "black", 30, 5)

ABOVE TRANSFORMS INTO:

def makeHead(x, y, color):
   # head
   makeRectangle(x, y, color, 80, 50)
   # eyes
   makeRectangle(x+25, y-10, "white", 30, 10)
   makeRectangle(x+30, y-15, "black", 5, 5)
   makeRectangle(x+40, y-15, "black", 5, 5)
   # mouth
   makeRectangle(x+20, y-35, "black", 30, 5)


makeHead(200, 200, "red")
makeHead(-200, -200, "yellow")

Notes:

You can reach me at ddjapri@ayclogic.com for any questions.

Class notes: https://drive.google.com/drive/folders/1JIaswYI_MssVSv7icxgYPd_LblYQvOVO?usp=sharing

Details

Date:
July 30
Time:
7:00 pm - 8:00 pm
Event Categories:
,