Introduction to Basic Python Turtle Tutorial

Slide Note
Embed
Share

"Learn the basics of Python with the Turtle module through a step-by-step tutorial. Follow along as you create simple designs and explore the world of programming with Python's Turtle graphics."


Uploaded on Sep 28, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Turtle Turtle PYTHON BASIC TUTORIAL Design by : Design by : Abdullah Saremi Naeini

  2. FIRST import import turtle wn wn= =turtle.Screen turtle.Screen() () pat= pat=turtle.Turtle turtle.Turtle() () pat.forward pat.forward(100) pat.left pat.left(90) (90) pat.fd pat.fd(100) (100) wn.mainloop wn.mainloop() () turtle (100)

  3. SECOND import import turtle wn wn = = turtle.Screen turtle.Screen() () wn.bgcolor wn.bgcolor(" ("lightgreen wn.title wn.title("Hello, Tess!" ("Hello, Tess!") turtle lightgreen" ") ) # # Set the window background color Set the window background color ) # Set the window title # Set the window title mat= mat= turtle.Turtle turtle.Turtle() () mat.color mat.color("blue" mat.pensize mat.pensize(3 (3) ("blue") ) # # Tell ) Tell mat to mat to change her color change her color # # Tell Tell mat to mat to set her pen width set her pen width mat.forward mat.forward(50 mat.left mat.left(120 mat.forward mat.forward(50 (50) ) (120) ) (50) ) wn.exitonclick wn.exitonclick() ()

  4. THIRD import import turtle wn wn = = turtle.Screen turtle.Screen() () wn.bgcolor wn.bgcolor(" ("lightgreen mat= mat= turtle.Turtle turtle.Turtle() () mat.shape mat.shape( ("turtle" mat.color mat.color( ("blue" "blue") ) turtle lightgreen" ") ) "turtle") ) mat.penup mat.penup() size = 20 size = 20 for for i i in in range(30): range(30): mat.stamp mat.stamp() size = size + 3 size = size + 3 # Increase the size on every iteration # Increase the size on every iteration mat.forward mat.forward(size (size) ) # Move # Move mat along mat.right mat.right(24 (24) ) # # ... and turn her ... and turn her () # This is new # This is new () # Leave an impression on the canvas # Leave an impression on the canvas mat along wn.mainloop wn.mainloop() ()

  5. FOURTH import import turtle wn wn = = turtle.Screen turtle.Screen() () wn.bgcolor wn.bgcolor(" ("lightgreen wn.setup wn.setup(300,300) (300,300) pat= pat=turtle.Turtle turtle.Turtle() () turtle lightgreen" ") ) pat.color pat.color( ("red" pat.pensize pat.pensize(3) for for i i in in [0,1,2,3,4]: [0,1,2,3,4]: pat.forward pat.forward(30) pat.left pat.left(72) wn.mainloop wn.mainloop() () "red") ) (3) (30) (72)

  6. LAST import import turtle wn wn = = turtle.Screen turtle.Screen() () wn.bgcolor wn.bgcolor( (" "lightgreen wn.setup wn.setup(300,300) (300,300) pat= pat=turtle.Turtle turtle.Turtle() () def def square(x): square(x): for for i i in in range range(4): pat.forward pat.forward(x) pat.left pat.left(90) turtle lightgreen" ") ) (4): (x) (90) pat.color pat.color( ("red" for i in for i in range range(20): square(50) square(50) pat.left pat.left(18) wn.mainloop wn.mainloop() () "red") ) (20): (18)

  7. FRACTAL

  8. FRACTAL

  9. END

More Related Content