from random import *
avoid using asterisk *,as to its origin, it's very confusing
If you are going to use the module mutiple times,
from turtle import Turtle()
tom = Turtle()
If it's for just once, specify the module name, which contains the class when making a new object. To make things clear, expressive
import turtle
tim = turtle.Turtle()
from turtle as t
terry = t.Turtle()
Goal was to read the documentation and find the solution. I used command + F for the keyword searching. It was an interesting topic. It was useful to recap my knowledge.
from turtle import Turtle, Screen
import turtle
tim = Turtle()
tim.shape("classic")
import random
# random colour list
#colour = ["DarkSeaGreen1", "pink", "coral", "CadetBlue", "grey", "cyan"]
tim.width(2)
tim.speed(50)
direction = [0, 90, 180, 270]
#----------RGB colours -----------------------
turtle.colormode(255)
def random_color():
r = random.randint(0, 150)
g = random.randint(0, 150)
b = random.randint(0, 250)
tu = (r, g, b)
return tu
#----------Spirograph -----------------------
def draw_spiro(number):
tim.circle(100)
tim.setheading(number)
number += 10
number = 10
for i in range(100):
tim.pencolor(random_color())
tim.circle(100)
tim.setheading(number)
number += 15
for i in range(200):
tu = random_color()
tim.pencolor(tu)
tim.forward(20)
tim.setheading(random.choice(direction))
#-----------drawing Polygons---------------------------------
# def shapes(angle):
# shape = 360/angle
# for i in range(angle):
# tim.forward(50)
# tim.right(shape)
#
# for angle in range(3, 11):
# tim.color(random.choice(colour))
# shapes(angle)
screen = Screen()
screen.exitonclick()
turtle art 1. Spirograph
turtle art 2. Random Walk
turtle art 3.Polygons
Final Project. turtle art 4. Damien Hurst's Dots
It's quite satisfying looking at my turtle working hard lol
- I downloaded an image of "Dots" by Damien Hurst. By using colorgram, which helps me to extract colours used frequently in the image.
- I extracted RGB values and made it into a tuple format.
- I looped through coloured dots randomly to create a masterpiece.
import colorgram
from turtle import Turtle, Screen
import random
import turtle
# colors = colorgram.extract('colordots.jpg', 10)
#
# rgb_colors = []
# for color in colors:
# r = color.rgb.r
# g = color.rgb.g
# b = color.rgb.b
#
# new_color = (r, g, b)
# rgb_colors.append(new_color)
# # rgb = color.rg
# # rgb_colors.append(rgb)
#
#
# print(rgb_colors)
#
# first_color = colors[0]
# rgb = first_color.rgb
# print(rgb)
tur = Turtle()
# tur.shape("circle")
# tur.speed(5)
# tur.dot(20, "blue")
# tur.color("blue")
# tur.stamp()
# tur.forward(120)
color_list = [(202, 216, 243), (138, 165, 199), (216, 147, 109), (30, 39, 60), (205, 135, 143), (52, 107, 153), (140, 182, 165)]
turtle.colormode(255)
def random_color():
num = random.randint(0, 6)
co = color_list[num]
return co
def dots():
for dot in range(10):
tur.pencolor(random_color())
tur.dot(20)
tur.penup()
tur.fd(50)
tur.shape("turtle")
tur.penup()
i = -200
for dot in range(10):
tur.setposition(-200, i)
dots()
i += 50
tur.hideturtle()
screen = Screen()
screen.exitonclick()
The article provides a clear and structured overview of Python basics, especially focusing on exception handling and file operations. It is informative for beginners but could be even more engaging with more visual examples or interactive elements. Just like on https://colorearw.net/, where kids can download free printable PDF coloring pages, adding visual aids would enhance the learning experience.
Printable coloring pages have become a popular activity for children and adults alike, offering a fun and creative outlet. These pages feature a variety of designs, from intricate mandalas to cartoon characters, allowing individuals to express their artistic flair. Accessible online, Printable coloring pages can be downloaded and printed at home, making them a convenient option for family entertainment or stress relief. Engaging with these pages can enhance focus and relaxation, serving as a therapeutic tool for many. Whether for a rainy day or a planned art session, printable coloring pages provide endless opportunities for creativity and enjoyment.