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

Re: Python Programming : Turtle Races 

By: Zimbler0 in 6TH POPE | Recommend this post (1)
Sat, 23 May 20 12:57 AM | 28 view(s)
Boardmark this board | 6th Edition Pope Board
Msg. 00479 of 60014
(This msg. is a reply to 00405 by Decomposed)

Jump:
Jump to board:
Jump to msg. #

Decomposed > Grrr. The indenting didn't survive.


Is OK Boss.
I must have figured it out.

Uploaded Image

Thanks.
Zim.




Avatar

Mad Poet Strikes Again.




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

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.


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