Giter VIP home page Giter VIP logo

turtle_race's Introduction

Turtle_Race - Survival of the fastest

Turtle_Race_Finished_-_Google_Chrome_2021-07-13_23-44-16_Trim_AdobeCreativeCloudExpress.1.mp4

ALgorithm:

  1. Start.
  2. Import the turtle module.
  3. Import Random module.

__________________________________ START THE TURTLE ___________________________________

  1. Create a new turtle t using turtle() function.
  2. Set turtle speed to ten using speed() function.
  3. Move the turtle from current position to (-140,140). (position can be set accordingly)
  4. Create a variable z and assign value 0 to it .

__________________________________ RACING TRACK ________________________________________

  1. Iterate the for loop 15 times.
  2. Write text at the centre position using the write() function.
  3. Rotate the turtle right by 90 degrees using the right() function.
  4. Move the turtle forward 10 steps using forward function().
  5. Pull back the pendown on screen using the pendown() function.
  6. Move the turtle forward 150 steps.
  7. Move the turtle backward 160 steps.
  8. Rotate the turtle left by 90 degrees using left() function.
  9. Move the turtle forward 25 steps.

________________________ Turtle 1 ________________________

  1. Create a turtle t1.
  2. Pen up.
  3. Move the turtle from its current position to (-160,104).
  4. Change the turtle color to HOT PINK using the color() function.
  5. Set the shape to turtle using shape() function.

________________________ Turtle 2 ________________________

  1. Create a turtle t2.
  2. Repeat the steps 20-23 with its position to(-160,66) and TURQUOISE color

________________________ Turtle 3 ________________________

  1. Create a turtle t3.
  2. Repeat the steps 20-23 with its position to(-160,28) and GOLD color.

________________________ Turtle 4 ________________________

  1. Create a turtle t4.
  2. Repeat the steps 20-23 with its position to (-160,0) and DARK ORCHID color.

__________________________________ WINNER __________________________________

  1. Any of the turtles reaches the coordinates of finish line (220) first, will be declared the winner.
  2. If t1 position is greater than 220 29.1) Print “Pink Turtle won the Race”
  3. If t2 position is greater than 220 30.1) Print “Blue Turtle won the Race”
  4. If t3 position is greater than 220 31.1) Print “Yellow Turtle won the Race”
  5. If t3 position is greater than 220 32.1) Print “Orchid Turtle won the Race”

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.