Outline for January 11
Reading: Wentworth et al., §3.1, 3.4.1
Due: Homework 1, due on January 18 at 11:55pm
- chaos program, incomplete version [chaos.py]
- Comments
- Function input() gets input as a string from user
- Function float() converts data to a floating point number
- Assignment to variable; evaluate right hand side first
- For loop generally
- Built-in range() function
- Index variable i initialized to 0
- Expression using multiplication, subtraction, and variables
- Printing a number
- Behavior with initial values of 0.25 and 0.26
- Lack of error checking: what happens if I enter -0.01?
- Turtle graphics
- What turtle is; import turtle
- Drawing a figure: a box with a hat [tbox.py]
- Set up the window to draw in: Screen()
- Create the turtle: Turtle
- Cursor for drawing
- Move cursor forward: forward, backward()
- Turn cursor: left(), right()
- Wait for the window to close: mainloop()
- Titles, background, and such [tfancybox.py]
- Window
- Color of the window background: background()
- Title of the window: title
- Turtle, more properly called “pen”
- Shape of the turtle: shape()
- Speed of the drawing: speed()
- Color of the drawn line: color()
- Thickness of the line (pixels): pensize()
- Hide the turtle: hideturtle()
- Plotting points and graphing
- Drawing lines: penup(), pendown()
- Move turtle: setpos()
- Write text: write()
- Draw a dot at the current position: dot() [tchaosdots.py]
- Draw a line from the current position to another: goto() [tchaosline.py]