ZEdKasat

Turtle race

May 28th, 2021 (edited)
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. from turtle import *
  2.  
  3. tom = Turtle()
  4. jerry = Turtle()
  5.  
  6. tom.color("green")
  7. jerry.color("blue")
  8.  
  9. tom.shape("square")
  10. jerry.shape("circle")
  11.  
  12. tom.penup()
  13. tom.goto(-250, 100)
  14. tom.pendown()
  15. jerry.penup()
  16. jerry.goto(-250, -100)
  17. jerry.pendown()
  18.  
  19. finish_line = Turtle()
  20. finish_line.penup()
  21. finish_line.goto(250, 150)
  22. finish_line.pendown()
  23. finish_line.goto(250, -150)
  24.  
  25.  
  26. tom_score = 0
  27. jerry_score = 0
  28.  
  29. from random import randrange
  30.  
  31. while tom_score < 500 and jerry_score < 500:
  32.     t = randrange(10, 40)
  33.     j = randrange(10, 40)
  34.  
  35.     tom.forward(t)
  36.     tom_score = tom_score + t
  37.  
  38.     jerry.forward(j)
  39.     jerry_score = jerry_score + j
  40.  
  41. done()
Add Comment
Please, Sign In to add comment