There has been some confusion about the in-class Activities and what to turn in. For this Activity, I want to make it explicitly clear.
Create a single Python program called shapeFunctions.py. Put a HEADER at the top of the program using COMMENTS as shown in class.
Example Heaader:
# Activity 4 Functions with Parameters
#
# This program demonstrates writing and calling functions with parameters
# by drawing shapes with different characteristics to the graphics canvas.
#
# Author: Your Name Your Section 1 (8AM) -or- 2 (11AM)
#
# Date: 9/2/2022
#
Note: All future programs that you write will have a header similar to this one
Also, in each function that you write, include a comment that describes what the function does for example, this might be the comment for the first function:
# This function draws a square of size 75 at the current location of the turtle
def fixedSquare():
When complete, this file should contain the five functions described below. You should have code that calls each one of the functions TWICE. Each time the function is called, it should produce a different drawing. For the first function, have the turtle use two different starting locations. For all the rest, change the parameter list so that it is different for the two calls.
Remember that if you want to use comments to silence out parts of Python instructions, use #
. For example,
#print("This is commented out by the # symbol")
print("This is not commented out")
print("This also is not commented out") # but this part is a comment
Write a function called fixedSquare() with no parameters that draws a square from the turtle’s current location that has a side length of 75 pixels.
Write a function called customSquare() with one parameter that draws a square from the turtle’s current locations whose side length is specified by the input parameter. (i.e a call to this function, customSquare(100), would draw a square at the current location that has a side length of 100).
Write a function called customRectangle() with two parameters. The first parameter is the height of the rectangle, and the second parameter is the width of the rectangle. (i.e. a call to this function, customRectangle(50, 150), would draw a rectangle 50 pixels in height and 150 pixels wide).
Write a function called placeRectangle() that takes four parameters. The first two are the x and y locations of where the rectangle should be drawn, and the last two are the height and width of the rectangle. (i.e. a call to this function, placeRectangle(-100, 100, 75, 200) would draw a rectangle whose UPPER LEFT corner is at (-100, 100) that is 75 pixels in height and 200 pixels wide.
As the instructions stated. You must write additional code to call each of these functions TWICE. Here is an example of a pair of calls to customSquare():
customSquare(88)
t.penup()
t.goto(-200, -200)
customSquare(111)
Make sure you saved your work and that it runs without errors. Submit your shapeFunctions.py
file on Moodle.