What is python turtle graphics and its commands
The Python Turtle Library is a really cool Python library that gives users to draw various awesome shapes. How to draw propose your girlfriend using python turtle? Let’s try this ,
How to Impress a girl’s heart using python heart: https://iterathon.tech//how-to-impress-a-girlfriend-heart-using-python/
Turtle graphics
Turtle graphics is a popular way of introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert, and Cynthia Solomon in 1967.
After getting into the link. You have to some basics of a turtle. Install comment: pip install turtle for windows, for mac python3 -m pip install turtle.
Link to know about turtle graphics: https://docs.python.org/3/library/turtle.html
Turtle Commands
Methods in turtle Module
turtle.forward()
- turtle.forward() moves the turtle forward by specified steps.
turtle.backward()
- turtle.backward() moves the turtle backward by specified steps.
turtle.left()
- turtle.left() takes a number of degrees which you want to rotate to the left.
turtle.right()
- turtle.right() takes a number of degrees which you want to rotate to the right.
turtle.reset()
- turtle.reset() clears the drawing and leaves it empty.
turtle.shape()
- turtle.shape() change the shape of the turtle.
turtle.exitonclick()
- turtle.exitonclick() closes the window when you click the turtle.
turtle.undo()
- turtle.undo() is used to undo the last action performed on the turtle.
turtle.color()
- turtle.color() to set the color of the turtle.
turtle.hideturtle()
- turtle.hideturtle() to hide the turtle from the screen.
turtle.showturtle()
- turlte.showturtle() to show the turtle from the screen.
turtle.pendown()
- turtle.pendown() to draw a line while moving the turtle.
turtle.penup()
- turtle.penup() doesn’t not draw the line while moving the turtle.
turtle.clear()
- turtle.clear() clears the drawing from the graphics window leaving the turtle in its current position.
turtle.circle()
- turtle.circle() to draws a circle.
Program
Example Program draw a triangle using turtle graphics
#import turtle and time module
import turtle
import time
#turtle commands to draw triangle
turtle.color("green")
turtle.forward(70)
turtle.left(120)
turtle.forward(70)
turtle.left(120)
turtle.forward(70)
#To hold a triangle for 10 seconds
time.sleep(10)
Related Post
What are Python Tkinter and Its commands: https://cybrblog.tech/what-are-python-tkinter-and-its-commands/
Random Password Generator in Python: https://iterathon.tech//random-password-generator-in-python/
How to send Gmail using python | Just 2 lines: https://iterathon.tech//how-to-send-gmail-using-python-just-2-lines/
NERD ❣