Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9a3110d

Browse files
Update readme.md
1 parent 195b339 commit 9a3110d

File tree

1 file changed

+51
-1
lines changed
  • Python Projects/Intermediate Games/TurtleSpot Painting

1 file changed

+51
-1
lines changed

‎Python Projects/Intermediate Games/TurtleSpot Painting/readme.md‎

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,57 @@
33

44
https://user-images.githubusercontent.com/67270567/226451638-85522054-b02e-4672-8322-7dafec1b1f05.mp4
55

6+
Press Play to see the Output
67

8+
# Line by Line Explanation of the code
79

10+
```python
11+
import turtle as turtle_module
12+
```
13+
1. This line imports the turtle module, which provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. It's imported as turtle_module to make it easier to use throughout the code.
814

9-
Press Play to see the Output
15+
```python
16+
turtle_module.colormode(255)
17+
```
18+
2. This line sets the color mode for the turtle to RGB color values. The colormode() function specifies the maximum value that can be used for each RGB color value, and here it's set to 255, which is the maximum value for an 8-bit color depth.
19+
20+
```python
21+
tim = turtle_module.Turtle()
22+
```
23+
3. This line creates a new turtle object called tim. The Turtle() function creates a new turtle object, which is used to draw on the screen.
24+
25+
```python
26+
tim.speed("fastest")
27+
```
28+
4. This line sets the speed of the turtle to the fastest possible speed. The speed() function sets the speed of the turtle to a predefined value, or to a number between 0 and 10, where 0 is the fastest possible speed.
29+
30+
```python
31+
tim.penup()
32+
```
33+
5. This line lifts the pen up so that the turtle does not leave any trails while moving. The penup() function lifts the pen up, so that subsequent movements of the turtle will not be drawn on the screen.
34+
35+
```python
36+
tim.hideturtle()
37+
```
38+
6. This line hides the turtle so that it is not visible while moving. The hideturtle() function hides the turtle from view, so that it doesn't interfere with the drawing on the screen.
39+
40+
```python
41+
color_list = [(202, 164, 109), (238, 240, 245), (150, 75, 49), (223, 201, 135), (52, 93, 124), (172, 154, 40), (140, 30, 19), (133, 163, 185), (198, 91, 71), (46, 122, 86), (72, 43, 35), (145, 178, 148), (13, 99, 71), (233, 175, 164), (161, 142, 158), (105, 74, 77), (55, 46, 50), (183, 205, 171), (36, 60, 74), (18, 86, 90), (81, 148, 129), (148, 17, 20), (14, 70, 64), (30, 68, 100), (107, 127, 153), (174, 94, 97), (176, 192, 209)]
42+
```
43+
7. This line creates a list of RGB color values that will be used to color the dots. Each tuple in the list represents an RGB color value.
44+
45+
```python
46+
tim.setheading(225)
47+
tim.forward(300)
48+
tim.setheading(0)
49+
```
50+
8. These lines set up the initial position of the turtle. The setheading() function sets the direction that the turtle is facing, where 0 is towards the right side of the screen. The forward() function moves the turtle forward by the specified number of pixels.
51+
52+
```python
53+
number_of_dots = 100
54+
```
55+
9. This line sets the number of dots to be painted.
56+
```python
57+
for dot_count in range(1, number_of_dots + 1):
58+
```
59+
10. This line sets up a for loop that will iterate from 1 to the total number of dots. The range() function creates a sequence of numbers

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /