Outline for April 10, 2014
Reading
:
text
, § 3
Due
: April 17, 2014
import
statement
import math
[
hypotnoex1.py
]
Need the “math.” before “sqrt”
from math import sqrt
[
hypotnoex.py
]
Do not need the “math.” before “sqrt”
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
]
Functions [
hello.py
]
What functions are
Defining them
Using them
Quick look at using them [
quad.py
]
Passing values to functions
Returning values from functions
The
right
way to do quad.py [
quad-c.py
]
You can also obtain a PDF version of this.
Version of April 10, 2014 at 4:18PM