Difference between revisions of "Turtle - House Function Assignment"

From WLCS
(Created page with "'''Objectives:''' * The student will create a program that defines and calls a function to draw houses * After creating this program, the student will be able to: ** Define a Pyt...")
 
 
(7 intermediate revisions by the same user not shown)
Line 13: Line 13:
 
# At the top of your program, you should have '''from turtle import *'''
 
# At the top of your program, you should have '''from turtle import *'''
 
# Define a function named '''house''' that draws a house like the one below
 
# Define a function named '''house''' that draws a house like the one below
 +
#* House - 100x100
 +
#* Door - 40x20
 +
#* Window - 20x20
 +
#* Roof - 75 each side with a 45 degree angle
 
# Make 3 goto() and 3 house() function calls
 
# Make 3 goto() and 3 house() function calls
  
Line 21: Line 25:
 
   #YOUR CODE HERE
 
   #YOUR CODE HERE
  
 +
penup()
 
goto(-200,0)
 
goto(-200,0)
 +
pendown()
 
house()
 
house()
 +
penup()
 
goto(200,0)
 
goto(200,0)
 +
pendown()
 
house()
 
house()
 +
penup()
 
goto(0,200)
 
goto(0,200)
 +
pendown()
 
house()
 
house()
 +
 +
exitonclick()
 
</source>
 
</source>
 +
 +
[[File:house.png]]

Latest revision as of 09:52, 9 February 2012

Objectives:

  • The student will create a program that defines and calls a function to draw houses
  • After creating this program, the student will be able to:
    • Define a Python function
    • Make a Python function call

Resources:

Directions:

  1. Open Wing IDE
  2. Create a Python program named houses
  3. At the top of your program, you should have from turtle import *
  4. Define a function named house that draws a house like the one below
    • House - 100x100
    • Door - 40x20
    • Window - 20x20
    • Roof - 75 each side with a 45 degree angle
  5. Make 3 goto() and 3 house() function calls
from turtle import *

def house():
  #YOUR CODE HERE

penup()
goto(-200,0)
pendown()
house()
penup()
goto(200,0)
pendown()
house()
penup()
goto(0,200)
pendown()
house()

exitonclick()

House.png