Draw Ram Naam using Python

Hello Friends! Aaj ke is post me mei apko batane ja raha hu ki ap Python ki help se Ram Naam kaise draw kar sakte hai, to ap iske baare me knowledge lena chahte he to is article ko last tak padhe, bahut hi saral aur simple topic-Draw Ram Naam using Python.
Draw Ram Naam using Python

Draw Ram Naam using Python

Hum is Program ko step by step samjhenge: 

from turtle import*

Yah ek Python statement he jo turtle module se sabhi naamon (functions, classes, aur variables) ko current namespace me import karta hai.

Turtle module ek built-in python module hai, jo graphics aur animations banane ke liye ek simple graphics library pradaan karta hai, yeh apko screen par ek turtle wale object ko control karne ki anumati deta hai, jo move kar sakta hai aur alag-alag shape ki drawing bana sakta hai.

Star symbol(*) ka use kar ke turtle module se sabhi naam import karke ap sidhe forward(), backward(), left(), right(), circle(), penup(), pendown() etc jaise functions aur methods ka use kar sakte hai.

Yah dhyan rakhna bahut important hai ki “import *” ka use aam taur par bad practice mana jata hai, kyuki isse naamon me takarav ho sakta hai aur yah determine karna muskil ho sakta hai, ki kuch naam kaha se aye hai, aamtaur par module se specific naam import karne ya module prefix ke sat naamon ka use karne ki anumati di jati hai (example turtle.left()), ye better code readability provide karta hai.

import numpy

Yah ek python statement he jo numpy module ko current namespace me import karta hai, numpy module python ke liye ek third-party library hai jo milti-dimensional arrays aur matrices, mathematical functions etc k liye support provide karta hai.

from time import*

Time module ek built-in python module hai, jo time aur time se related various work provide karta hai, yah apko time values ke sat kaam karne, measure time intervals aur time se related operations karne ki anumati deta hai.

global function

Statement global x, y ka use kisi function ke bhitar yeh specified karne ke liye kiya jata hai ki variables x aur y global variables hai, jiska meaning hai ki unhe function ke bahar global scope me defined variables ke roop me mana jana chahiye. Yah function ko global variables x aur y tak access aur modify karne ki anumati deta hai.

def function

Python me, function nirdeshon ke ek set ko ek sath grouped karne ka ek tarika hai, taki ap code ko doharaye bina usko kai bar use kar sake.

Kisi function ko define karne ke liye, ap function naam aur parentheses ki ek jodi ke pehle def keyword ka use karte hai, parentheses ke andar ap koi bhi input ya information specified kar sakte hai, fir ap indented block ke andar function ke liye instructions ya code likhte hai.
Jab ap function ka use karna chahte hai, to ap ise iske naam se call karte hai aur koi bhi required inputs provide karte hai, function iske andar code executes karta hai aur vaikalpik roop se result ko vapas vahi lauta sakta hai, jaha se ise call kiya gaya tha.

Kuch important functions jo program me use huye he:

  • bgcolor() function ka use background ka color dene ke liye kiya jata hai, yaha hum background ko black color de rahe he.
  • speed() function ka use pen ki speed control karne ke liye kiya jata he.
  • color() function ka use pen ka color decide karne ke liye kiya jata he.
  • write() function ka use screen me kuch bhi likhne ke liye kiya jata hai.
  • penup() function ka use tab kiya jata hai jab hum screen par kuch bhi nahi draw kar rahe ho.
  • pendown() function ka use tab kiya jata he jab hum screen par kuch draw kar rahe ho.
  • goto() function ka use turtle ko x aur y axis me le jane ke liye kiya jata hai.
  • done() function ka use window screen ko freez karne aur program ko end karne ke liye kiya jata hai.

Draw Ram Naam using Python

from turtle import *
from time import *
import numpy

title("niTin KM")
bgcolor("black")
colormode(255)
speed(1)
sleep(2)

x= -200
y=200

def ram_name():
    c=tuple(numpy.random.randint
    (90, 255, 3))
    
    color(c)
    write("ram", font=("Arial", 
    10, "bold"))
   
def draw(i):
    global x, y    
    penup()
    goto(x,y)
    pendown()
    x-=i
    y-=15
    ram_name()

for _ in range(4):  
    draw(10)  

x-=15    
y+=23

for _ in range(7):  
    draw(-10) 

x= -150    
y=200

def line(meet=9):
    global x, y
    for _ in range(meet):
        penup()
        goto(x,y)
        pendown()
        y-=15
        ram_name()

line()        
x= -80
y =200
line(8)

for _ in range(3):
    x-=10
    y+=15
    penup()
    goto(x,y)
    pendown()
    ram_name()

for _ in range(5):
    x+=27
    penup()
    goto(x,y)
    pendown()
    ram_name()

x = 25    
y = 200
line()
x= -240
y = 215

for _ in range(14):
    penup()
    goto(x,y)
    pendown()
    x+=27
    ram_name()

hideturtle()    
done()
Output:-
Draw Ram Naam using Python
Video Link:- Click me
Agar apko yaha upar diya hua Draw Ram Naam using Python program pasand aya hoto please is article ko share kare.

Apka humari Website me aane ke liye Dhanyawaad!

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

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