Text Size
Text Size
Exit Full Screen
Python Mini
Show
Source Code
View Source Code in Full Screen
Open in New Tab
import random import time from turtle import Turtle tor1 = Turtle() tor2 = Turtle() tor3 = Turtle() tor4 = Turtle() tor5 = Turtle() tor6 = Turtle() tor7 = Turtle() tor8 = Turtle() x1 = 0 y1 = 100 tor1.setposition(x1, y1) tor1.color("red") x2 = 100 y2 = 100 tor2.setposition(x2, y2) tor2.color("orange") x3 = 100 y3 = 0 tor3.setposition(100, 0) tor3.color("gold") x4 = 100 y4 = -100 tor4.setposition(100, -100) tor4.color("green") x5 = 0 y5 = -100 tor5.setposition(0, -100) tor5.color("blue") x6 = -100 y6 = -100 tor6.setposition(-100, -100) tor6.color("purple") x7 = -100 y7 = 0 tor7.setposition(-100, 0) tor7.color("magenta") x8 = -100 y8 = 100 tor8.setposition(-100, 100) tor8.color("pink") def swapTor(t1, t2): oldx1 = t1.xcor() oldy1 = t1.ycor() oldx2 = t2.xcor() oldy2 = t2.ycor() t1.setposition(oldx2, oldy2) t2.setposition(oldx1, oldy1) for shuff in range(25): tortugas = [tor1, tor2, tor3, tor4, tor5, tor6, tor7, tor8] rTor1 = random.choice(tortugas) rTor2 = random.choice(tortugas) swapTor(rTor1, rTor2)
ch_TurtleShuffle_v2.py
( around 55 lines python code )
Published By:
EM5700
Published on
2019-12-14T20:44:12Z
Python Mini
- an
OYOclass
application,
own your own class today
.
Run
Result
×
Error message shows here