Python Turtle Art - Draw 3D Triangle and Star in Python

Is Program me humne Python Turtle Art “turtle” module ka use kiya hai, jo ek graphical library hai, jiska use karke hum asani se drawings bana sakte hai.
Python Turtle Art

Python Turtle Art - Draw 3D Triangle and Star in Python

Yaha hum apko, Python Turtle Art ka use karke Triangle kaise banaye ye bataenge.

  1. Sabse pehle, humne turtle module ko import kiya hai.
  2. Hum turtle ki speed control karne ke liye t.tracer() ka use karenge.
  3. Ab hum turtle ke liye kuch setting karenge, yaha humne pen ke size ko 2 set kiya hai aur upar uthane ke baad turtle ko (0,70) isthan par le gaye hai.
  4. Ab humne Triangle banane ke liye ek loop run kiya hai, is loop me turtle 260 unit ki duri chalta hai.
  5. Ab hum t.hideturtle() ka use kar ke turtle ko hide kar sakte hai, taki triangle banate time wah dikhayi na de.
  6. Last me hum t.done() ka use karke window screen ko rok sakte hai.
Is code ko apne Python software par yaha se copy aur paste kare.
import turtle as t
import colorsys
s=t.Screen()
t.title("Python Turtle Art")
t.tracer(2)
t.pensize(2)
t.bgcolor("black")
h=5
t.goto(0,70)

for n in range(260):
    c=colorsys.hsv_to_rgb(h,1,1)
    t.color(c)
    h+=0.007
    for p in range(4):
        t.forward(n)
        t.right(60)
        t.right(60)
    t.right(120)  
    t.hideturtle()
 
t.done()    
Output:-
Python Turtle Art
Video Link:- Click me

Yaha mei apko Python Turtle Art me Python Turtle ka use karke ek Star banane ka discription de raha hu.

  • Sabse pehle, humne turtle module ko import kiya hai.
  • Hum turtle ki speed control karne ke liye t.tracer() ka use karenge.
  • Ab hum Star banane ke liye ek loop chalaenge, jo 250 unit ki duri chalega.
  • Jab loop pura ho jaye, turtle ek star drawing bana chuka hoga.
  • Aanth me hum turtle ko hide kar sakte hai, taki star banane k baad wah dikhayi na de.
  • sab se last me hum t.done() ka use kar k window screen ko rok sakte hai.
Is code ko run karne ke baad apko ek star dikhayi dega.
import turtle as t
import colorsys
s=t.Screen()
t.title("Python Turtle Art")
t.bgcolor('black')
t.tracer(2)
m = 0.9
n=50

for i in range(250):
    c = colorsys.hsv_to_rgb(m,1,1)
    m +=0.005
    t.pencolor(c)
    t.right(90)
    t.forward(i+1)
    t.left(90)
    t.backward(i)
    t.circle(2, 1-n)
    t.left(120)
    t.circle(2+m, 1)
    t.hideturtle()
   
t.done()
Output:-
Python Turtle Art
Video Link:- Click me
Agar apko Triangle aur Star ki python turtle art ka use kar ke ye 3d drawings acchi lagi hoto please meri website programmingkakeeda ko share kare.
Humare Website me aane k liye apka Dhanyawaad!

एक टिप्पणी भेजें

0 टिप्पणियाँ
* Please Don't Spam Here. All the Comments are Reviewed by Admin.