<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Race game using python]]></title><description><![CDATA[<p dir="auto">import turtle<br />
from turtle import Turtle<br />
import random</p>
<p dir="auto">turtle.title('Turtle rance')<br />
turtle.bgcolor('grey')</p>
<p dir="auto">turtle.color('white')<br />
turtle.penup()<br />
turtle.goto(-100, 200)<br />
turtle.write('Turtle race', font=('Arial', 30, 'bold'))</p>
<p dir="auto">turtle.goto(-400, -200)<br />
turtle.color('brown')<br />
size = [800, 120, 800, 120]<br />
turtle.speed(100)<br />
turtle.begin_fill()</p>
<p dir="auto">for i in range(4):<br />
turtle.forward(size[i])<br />
turtle.right(90)<br />
turtle.end_fill()</p>
<p dir="auto">turtle.shape('square')<br />
turtle.color('dark green')<br />
for i in range(10):<br />
turtle.goto(300, 150 - (i*30))<br />
turtle.stamp()</p>
<p dir="auto">for i in range(10):<br />
turtle.goto(310, 140 - (i*30))<br />
turtle.stamp()</p>
<p dir="auto">t1 = Turtle()<br />
t1.penup()<br />
t1.goto(-200, 0)<br />
t1.shape('turtle')<br />
t1.color('yellow')</p>
<p dir="auto">t2 = Turtle()<br />
t2.penup()<br />
t2.goto(-200, 50)<br />
t2.shape('turtle')<br />
t2.color('blue')</p>
<p dir="auto">t3 = Turtle()<br />
t3.penup()<br />
t3.goto(-200, 100)<br />
t3.shape('turtle')<br />
t3.color('black')</p>
<p dir="auto">t4 = Turtle()<br />
t4.penup()<br />
t4.goto(-200, -50)<br />
t4.shape('turtle')<br />
t4.color('red')</p>
<p dir="auto">d1 = 0<br />
d2 = 0<br />
d3 = 0<br />
d4 = 0</p>
<p dir="auto">for i in range(200):<br />
ran1 = random.randint(1, 25)<br />
ran2 = random.randint(1, 25)<br />
ran3 = random.randint(1, 25)<br />
ran4 = random.randint(1, 25)</p>
<pre><code>t1.forward(ran1)
d1 += ran1
t2.forward(ran2)
d2 += ran2
t3.forward(ran3)
d3 += ran3
t4.forward(ran4)
d4 += ran4

if d1 &gt;= 499 or d2 &gt;= 499 or d3 &gt;= 499 or d4 &gt;= 499:
    distance = {d1:'yellow', d2:'blue', d3:'black', d4:'red'}

    turtle.goto(-350, 290)
    turtle.write('Final result', font=('Arial', 20, 'bold'))

    one = max(distance.keys())
    turtle.goto(-350, 260)
    turtle.write('1:{}'.format(distance[one]), font=('Arial', 13))
    del distance[one]

    two = max(distance.keys())
    turtle.goto(-350, 240)
    turtle.write('2:{}'.format(distance[two]), font=('Arial', 13))
    del distance[two]

    three = max(distance.keys())
    turtle.goto(-350, 220)
    turtle.write('3:{}'.format(distance[three]), font=('Arial', 13))
    del distance[three]

    four = max(distance.keys())
    turtle.goto(-350, 200)
    turtle.write('4:{}'.format(distance[four]), font=('Arial', 13))

    break
</code></pre>
<p dir="auto">turtle.hideturtle()<br />
turtle.done()</p>
]]></description><link>https://lankadevelopers.lk/topic/254/race-game-using-python</link><generator>RSS for Node</generator><lastBuildDate>Thu, 11 Jun 2026 22:24:58 GMT</lastBuildDate><atom:link href="https://lankadevelopers.lk/topic/254.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 May 2019 07:42:12 GMT</pubDate><ttl>60</ttl></channel></rss>