Final illustration: This app was created with total modularity. Each component was developed independently and did not rely on the procedures of the other modules, as long as the inputs and outputs were correct.
Overviewed using Python documentation to learn about attributes and methods in a class.
Used refactoring to rename an object throughout the code.
Reviewed importing modules:
Keyword / module name imports
Import module = acceptable, but makes references in the code longer (they will need to reference the module for every call.
From module import module_item = ideal when possible. Keeps code shorter / cleaner.
Avoid: from module import *
Reviewed aliasing modules (e.g. import turtle as t).
Useful for long-named modules
Some modules require package downloading.
Learned about tuples.
Tuples are similar to list, containing multiple values. However, tuples are immutable (elements cannot be added, changed or removed).
Several “turtle challenges”
Had the turtle draw a dashed line.
Had the turtle draw all of the shapes from 3 to 10 sides with a random color for each shape.
Had the turtle take a “random walk” (10 pace walks with random heading changes in between)
Had the turtle create a Hirst Dot Painting
Reviewed Event Listeners
Reviewed passing functions as arguments
Higher order functions can accept other functions as arguments / parameters.
Try to use keyword arguments in these scenarios.
Discussed creating multiple objects from the same class.
Discussed object states.
Etch-a-sketch (Turtle Graphics project)
Turtle Race – Generate 6 turtle objects and have them race. Have the user bet on who the winner will be.
Introduced Snake project (popular game on Nokia phones) and the smaller elements that will need constructed.
Part 1 – Used for loop to generate snake segment objects and move them to their starting position.
Part 2 – Reviewed screen tracing / when to update the screen. Discussed making the snake move (the snake actually moves from aft to forward as trailing segments assume the position of their predecessor).
Part 3 – Split code into classes for OOP. Created the create-snake segment
Part 4 – Setup event listeners to accept keyboard inputs to move the snake
Remainder of game functionality to be completed on Day 21.