(Extra Credit) Class Extension Turtlehack

by Elliott Hauser

24 Nov 2022

Submit a well-formatted pull request to our class website with embedded Trinket program(s) for the assignment below. Complete this on your own, using any class materials you need (including the additional resources on the syllabus). Do not look at other students’ submissions until after you’ve completed your work.

Include a thoughtful reflection, and use Markdown as needed to make your writing about your code clear and understandable to others. Your reflection should articulate what you think you’ve learned and any concepts that are still fuzzy to you. Did you encounter frustrating situations? Did you feel a lightbulb turn on?

In your program, remember to leave comments via Python’s # or using Trinket’s inline comments as needed to orient your reader.

After your programs are done, check other students’ work and other resources online if you had questions.

__

Extend the Turtle class such that your new class changes the color and starting position of the resulting object in the __init__ method.

Then, instantiate four objects (or more) of your new Turtle-based class.

Then, add (at least) one new method to your class that enables it to make a shape when called. Your method should accept at least one custom parameter. Call this method on all four instantiated objects with different arguments to demonstrate how they change your custom objects’ behavior.

For instance, if your method draws a triangle and then hides the turtle, and you choose method parameters that position your custom turtles in the four quadrants of the screen before drawing the triangle, your resulting program will show four different-colored triangles in the four quadrants of the screen.

To optionally challenge yourself, consider:

  • instantiating your custom Turtles in a loop, or otherwise using loops to generate complex behavior from few lines of code
  • using the random module to generate random integers, or choose random colors from a list you made.
  • accepting parameters in your custom class

Have fun and experiment!

Elliott Hauser is an Assistant Professor at the UT Austin iSchool. He's hacking education as one of the cofounders of Trinket.io. Find Elliott Hauser on Twitter, Github, and on the web.