« 6TH POPE Home | Email msg. | Reply to msg. | Post new | Board info. Previous | Home | Next

Re: Python Programming : Turtle Races

By: Decomposed in 6TH POPE | Recommend this post (0)
Fri, 22 May 20 4:42 AM | 22 view(s)
Boardmark this board | 6th Edition Pope Board
Msg. 00405 of 60014
(This msg. is a reply to 00404 by Zimbler0)

Jump:
Jump to board:
Jump to msg. #

Zimbler0:

Re: "Care to share?"
Happy to!

And, no, I haven't done anything with tkinter. This is turtle graphics.


import turtle
import random

number_of_turtles = 8

turtles = [] # Create an empty list.

for i in range(number_of_turtles): # create a turtle, add it to the list
t = turtle.Turtle()
turtles.append(t) # Add it to the list
t.shape('turtle')
t.penup()
t.right(90) # Move each turtle to its own starting place based on the value of i
t.forward(20*i)
t.left(90)

for i in range(100):
for t in turtles: # for each turtle in the list, advance it a random distance. In this case, t is each
t.forward(random.randint(0,6))

turtle.done() # end of program!!! 8 turtles will race with random results.
Grrr. The indenting didn't survive. I'll post the program again as an image.




Avatar

Gold is $1,581/oz today. When it hits $2,000, it will be up 26.5%. Let's see how long that takes. - De 3/11/2013 - ANSWER: 7 Years, 5 Months


- - - - -
View Replies (2) »



» You can also:
- - - - -
The above is a reply to the following message:
Re: Python Programming : Turtle Races
By: Zimbler0
in 6TH POPE
Fri, 22 May 20 4:30 AM
Msg. 00404 of 60014

Was that done in Tkinter?
Or something else?

Is that about twelve lines of code?
Care to share?

Zim.


« 6TH POPE Home | Email msg. | Reply to msg. | Post new | Board info. Previous | Home | Next