Outline for December 2, 2024

Reading: none
Due: Homework 5, due December 6; Completed project, due December 12


All work except the completed project must be submitted by 11:59pm on December 6. Anything submitted after that will not be graded.

  1. Writing a program with objects [war.py]

  2. Turtle graphics
    1. What turtle is; import turtle

  3. Drawing a figure: a box with a hat [tbox.py]
    1. Set up the window to draw in: Screen()
    2. Create the turtle: Turtle()
    3. Cursor for drawing
    4. Move cursor: forward, backward(), left(), right()
    5. Wait for the window to close: mainloop()

  4. Titles, background, and such [tfancybox.py]
    1. Window
      1. Color of the window background: background()
      2. Title of the window: title()
    2. Turtle, more properly called “pen”
      1. Shape of the turtle: shape()
      2. Speed of the drawing: speed()
      3. Color of the drawn line: color()
      4. Thickness of the line (pixels): pensize()
      5. Hide the turtle: hideturtle()

  5. Plotting points and graphing
    1. Drawing lines: penup(), pendown()
    2. Move turtle: setpos()
    3. Write text: write()
    4. Draw a dot at the current position: dot() [tchaosdots.py]
    5. Draw a line from the current position to another: goto() [tchaosline.py]

  6. Curves in turtle
    1. Drawing parts of a circle [tcircle.py]
    2. Drawing a curve [tcurve.py]

  7. Turtle race [turtlerace.py]
    1. Create turtles
    2. Create goals
    3. Create die
    4. Program structure:
      1. Check to see if either turtle has reached its goal; if so, that turtle wins
      2. If not, ask the player whose turn it is to roll the die (ie, press ENTER)
      3. Select random number from die list
      4. Advance turtle appropriately (multiply by LENGTH_OF_STEP)
      5. Loop until someone wins

A very good tutorial (and the turtle race) is https://realpython.com/beginners-guide-python-turtle


UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
ECS 235A, Computer and Information Security
Version of December 2, 2024 at 9:19AM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh