[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

[Turtle] Clash camera race with Python

Hello.
410 Error
System Solution Department is cute.

I haven't been feeling well lately due to the humidity, heat, and resident tax, so this time use
turtle let the turtles compete. You can do various things like the GIF image above, so please try moving your favorite turtle as much as you like.

Operating environment and full code

So without further ado,

OS used: Microsoft Windows 10 Pro
Python version: 3.10

from turtle import * from random import randint import time #line drawing for step in range(11): write(step, align='center') speed(80) right(90) forward(10) pendown() forward(150) penup() backward(160) left(90) forward(20) time.sleep(1) #Red Turtle red = Turtle() red.color('red') red.shape('turtle') red.penup() red.goto(0, -10) #Blue Turtle blue = Turtle() blue.color('blue') blue.shape('turtle') blue.penup() blue.goto(0, -30) #Yellow Turtle yellow = Turtle() yellow.color('orange') yellow.shape('turtle') yellow.penup() yellow.goto(0, -60) #Green Turtle green = Turtle() green.color('green' ) green.shape('turtle') green.penup() green.goto(0, -90) #Black Turtle black = Turtle() black.color('black') black.shape('turtle') black.penup () black.goto(0, 60) #MouseTurtle gray = Turtle() gray.color('gray') gray.shape('turtle') gray.penup() gray.goto(0, -120) #Rotate Turtle pink = Turtle() pink.color('pink') pink.shape('turtle') pink.penup() pink.goto(0, -150) time.sleep(3) #move each turtlex100 for kame in range(100): red.forward(randint(1, 2)) blue.forward(randint(-1, 3)) yellow.forward(randint(-3, 4)) green.forward(randint(-4) , 5)) black.right(90) gray.forward(randint(-3, -2)) pink.forward(randint(-10, 10))

Code explanation

Import each library.
In order to make the turtles run randomly, the random
time is for staging after placing the turtles and making them wait for a while, so it is OK even if it is not used.

from turtle import * from random import randint import time

Honestly, this is the only place I'm concerned about.
Starting from 0, repeat with for until 10 lines are drawn as a racetrack.

for step in range(11): write(step, align='center') speed(80) right(90) forward(10) pendown() forward(150) penup() backward(160) left(90) forward( 20)

Specify the color of the turtle using color().
* You can specify colors in more detail using
fillcolor() Specify the turtle shape with shape() and the initial placement coordinates with goto(). It's ok if you shift the subsequent cameras little by little while debugging.

#Red Turtle red = Turtle() red.color('red') red.shape('turtle') red.penup() red.goto(0, -10)

Rotate it with for so that it moves 100 times.
For each turtle, one of the numbers (number, number) is randomly selected.
This timeIt's a painAlthough I didn't mention it, it would probably create a good atmosphere if you displayed something like "Goal!" when you reach a goal.

for kame in range(100): red.forward(randint(1, 2)) blue.forward(randint(-1, 3)) yellow.forward(randint(-3, 4)) green.forward(randint(- 4, 5)) black.right(90) gray.forward(randint(-3, -2)) pink.forward(randint(-10, 10))

Turtlr is originally like a drawing library, but you can also use it like this just by adding turtle shape.
(For detailed instructions on how to use it, please refer
the official documentation I think it's a great introduction to Python, so please try it out in a cool, air-conditioned room.
See you then

If you found this article helpful , please give it a like!
13
Loading...
13 votes, average: 1.00 / 113
914
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author

Kawa Ken


A curious Poke○n who belongs to the System Solution Department.