turtle क्या है और इसे कैसे बनाते है ?

Turtle क्या है 

Turtle एक python का feature है जो कि drawing करने मे काम आता है । इसे ऐसे समझते है छोटे बच्चो के पास जो drawing book होती है white color की जिसमे वो जो चाहे वो बना सकते है । ठीक उसी प्रकार turtle मैं भी एक white screen होती है जिसमे हम जो चाहे वो बना सकते है हम cartoon बना सकते है , हम logo बना सकते है मतलब कुछ भी । ओर ये सब हम turtle को command देकर बना सकते है और इसको बनाने के लिए बोहोत से function है जिनमे से कुछ है turtle.forward(..), turtle.backward(..) etc . ओर ये जो function है ये turtle को move करते है । जैसे अगर हम turtle को राइट ले जाना है तो हमें turtle.right(..) function लिखना होगा । 

इसको बनाने की method क्या है ?

Turtle को plot करने की 4 steps है 

1. Import the turtle module 
2. Create a turtle to control 
3. Draw around using the turtle method
4. Run turtle.done()

Example :- 

import turtle 
wn = turtle.Screen()
wn.bgcolor('blue')
wn.title("my window")
s = turtle.Turtle()

for i in range(10):
s.forward(30)
s.right(40)
turtle.done()
Example :- 2
import turtle 
q = turtle.Turtle()
q.speed(21)
q.color('red')

for i in range(40):
q.circle(150)
q.left(50)
Example :- 
import turtle 

turtle.Screen().bgcolor("black")

t = turtle.Turtle()
t.speed(10)
t.pensize(10)
t.penup()

def drawcircle():
   t.setposition(0,-280)
   t.pendown()
   t.begin_fill()
   t.color('red')
   t.pencolor("white")
   t.circle(300)
   t.end_fill()
   t.penup()
 
drawcircle()  

turtle.done()

Post a Comment

0 Comments