Tutorials

  • image not found

Tutorial 2 : Code to Play in Python

In this Tutorial , we will build two famous classic games :

  • Snake
  • Pacman

Stage 1 :

  • Learn about Python’s Turtle Module
  • Set Up the Screen
  • Draw shapes
  1. Create a new Python file using IDLE.
  2. Write the following code line by line
    from turtle import *
    setup(width=600,height=600)
    title(“My Screen”)
    bgcolor(“red”)
    done()
  3. Save the Python file.
  4. Go to Run Menu and click Run Module . you have to get a new window opened with red background color .
  5. try to change the size of the window , title and background color .
  6. then let’s draw a first shape using Turtle Module.
  7. add the following code before code done()
    forward(100)
    left(90)
    forward(100)
    left(90)
    forward(100)
    left(90)
    forward(100)
  8. so your code should look as the following :

    from turtle import *

    setup(width=600,height=600)
    title(“My Screen”)
    bgcolor(“red”)
    forward(100)
    left(90)
    forward(100)
    left(90)
    forward(100)
    left(90)
    forward(100)
    done()

  9. Run the code same what we did in step 4 : Go to Run Menu and click Run Module .
  10. To learn more . download the following python code and study each line

Stage 2 :

  • Stay tuned …

Buy Me a Coffee .
I Love coffee