Outline for January 11

Reading: Wentworth et al., §3.1, 3.4.1
Due: Homework 1, due on January 18 at 11:55pm


  1. chaos program, incomplete version [chaos.py]
    1. Comments
    2. Function input() gets input as a string from user
    3. Function float() converts data to a floating point number
    4. Assignment to variable; evaluate right hand side first
    5. For loop generally
      1. Built-in range() function
      2. Index variable i initialized to 0
      3. Expression using multiplication, subtraction, and variables
      4. Printing a number
    6. Behavior with initial values of 0.25 and 0.26
    7. Lack of error checking: what happens if I enter -0.01?
  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: forward, backward()
    5. Turn cursor: left(), right()
    6. 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]


UC Davis seal
Matt Bishop
Office: 2209 Watershed Science
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
You can also obtain a PDF version of this.
Version of January 11, 2019 at 11:35AM