Python Turtle Graphics // Python Project // Python Graphics // Mini Python Projects

Veröffentlicht am: 24 Juni 2021
auf dem Kanal: SOUMESH KAYASTA
98
3

make use of the turtle methods and functionalities, we need to import turtle.”turtle” comes packed with the standard Python package and need not be installed externally. The roadmap for executing a turtle program follows 4 steps:





Import the turtle module
Create a turtle to control.
Draw around using the turtle methods.
Run turtle.done().
So as stated above, before we can use turtle, we need to import it. We import it as :


from turtle import *
or
import turtle


After importing the turtle library and making all the turtle functionalities available to us, we need to create a new drawing board(window) and a turtle. Let’s call the window as wn and the turtle as skk. So we code as:


wn = turtle.Screen()
wn.bgcolor("light green")
wn.title("Turtle")
skk = turtle.Turtle()


Now that we have created the window and the turtle, we need to move the turtle. To move forward 100 pixels in the direction skk is facing, we code:


skk.forward(100)


We have moved skk 100 pixels forward, Awesome! Now we complete the program with the done() function and We’re done!


turtle.done()


So, we have created a program that draws a line 100 pixels long. We can draw various shapes and fill different colors using turtle methods. There’s plethora of functions and programs to be coded using the turtle library in python. Let’s learn to draw some of the basic shapes.
code-----------



Shape 1:
Code with soumesh Kayasta
import turtle

t = turtle.Turtle()
t.getscreen().bgcolor("black")
t.speed(100)
t.color("cyan")

x =0
while True:
t.circle(x)
x+=1
t.right(60)
if x == 180:
break

turtle.done()


like , subscribe and press Bell icon 🔔




#Turtle_Graphics #Python_Projects #Python


Auf dieser Seite können Sie das Online-Video Python Turtle Graphics // Python Project // Python Graphics // Mini Python Projects mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer SOUMESH KAYASTA 24 Juni 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 98 Mal angesehen und es wurde von 3 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!