-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapples.py
More file actions
76 lines (53 loc) · 2.9 KB
/
Copy pathapples.py
File metadata and controls
76 lines (53 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'''
Some turtle functions you can use to make your shapes
forward(<distance>) - This function takes a positive or negative number and
will move the turtle forward.
back(<distance>) - This function takes a positive or negative numbers and
it will move the turtle back.
right(<angle>) - This function takes a number that represents
angle in degrees. It will turn the turtle to its right
left(<angle>) - This functions takes an number that represents
an angle in degrees. It will turn the turtle to its left.
pencolor(<color>) - This functions takes a string that represents a color. The
turtle's pen will draw in that color. The possible color values can be found
at https://www.tcl.tk/man/tcl8.4/TkCmd/colors.htm
penup() - This function takes no parameters. When called it will
lift the turtle's pen up, the turtle will not draw when moved.
pendown() - This function takes no parameters. When called it will put the
turtle's pen down. It will draw when moved.
speed(<number>) - This function takes a number. It determines how fast the
turtle moves around the screen. Strangely enough if you want it to go as
fast as possible you have to pass it 0 as a parameter.
goto(<x>, <y>) - This function takes two numbers, a position along the x-axis
and a position along the y-axis. It will move the turtle to that position.
fillcolor(<color>) - This function takes a string that represents a color. The
color will be used to fill shape the turtle has made. In order to get the turtle
to fill the shape you have to use the begin_fill() function before the turtle
starts drawing the shape and the end_fill() function after it finishes for the
shape to be filled in.
begin_fill() - This function takes no parameters. It is put before the turtle
draws a shape that you want filled in.
end_fill() - This function takes no parameters. It is put after the turtle has
finished drawing a shape that you want filled in.
dot(<size>, <color>) - This function takes two parameters. The first is a
positive number that represents the diameter of the dot to be drawn by the
turtle. The second is a string that represents the color the dot should be.
BONUS:
circle(<radius>, <extent>, <steps>) - This function takes three parameters.
However you only have to put in the first one. The <radius> parameter is the
necessary parameter, it is a number that represents the radius of the circle.
The <extent> is optional. It represents an angle saying how much of the circle
should be drawn, if you don't put in anything for <extent> it will draw the whole
circle. If you put in 180, it will draw a half circle. The third parameter
<steps> is a number that represents how many steps the turtle should take to
draw the circle. Try setting <steps> as 5 to see what happens.
'''
from turtle import *
def triangle(side_length, fill_color):
fillcolor(fill_color)
pendown()
for i in range(3):
forward(side_length)
right(120)
print("I just turned right!")
triangle(50, "purple")