Jai Shree Ram using Python Turtle

Draw Jai Shree Ram using Python Turtle

Turtle graphics is a popular way for introducing programming to kids or beginners because it provides a visually appealing and interactive way to learn programming concepts. In Python, the turtle module is a standard library module that provides a simple drawing toolkit.

Here’s a brief introduction to the turtle module in Python:

Setting Up Turtle: To use the turtle module, you need to import it:

import turtle

Creating a Turtle: You can create a turtle object, which represents a pen that can be moved around the screen to draw:

t = turtle.Turtle()

Basic Turtle Commands: The turtle responds to various commands. Here are some basic ones:

forward(distance): Move the turtle forward by a specified distance.

backward(distance): Move the turtle backward by a specified distance.

left(angle): Turn the turtle left by a specified angle (in degrees).

right(angle): Turn the turtle right by a specified angle (in degrees).

penup(): Lift the pen off the drawing surface.

pendown(): Lower the pen to start drawing.

color(color): Set the pen color.

Example: Drawing a Square: Here’s a simple example that uses the turtle to draw a square:

import turtle

# Create a turtle
t = turtle.Turtle()

# Draw a square
for _ in range(4):
    t.forward(100)
    t.right(90)

# Close the turtle graphics window when clicked
turtle.exitonclick()

 

Drawing Text: You can also use the turtle module to write text on the screen:

t.write("Hello, Turtle!", font=("Arial", 12, "normal"))

This writes the text “Hello, Turtle!” in the specified font.

Controlling the Turtle Window:

turtle.speed(speed): Set the turtle’s speed.

turtle.bgcolor(color): Set the background color of the turtle window.

These are just some basic concepts to get started with the turtle module. It’s a fun way to learn programming concepts like loops, conditions, and functions in a visual and interactive manner. 

Now here is the main python program to draw Jai Shree Ram using Python Turtle for which you came here. 

from turtle import* 
title('Jai Shree Ram')
bgcolor('blue')
pensize(6)
pencolor("orange")

Ram_naam = ["जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम","जय श्री राम","जय श्री राम",
"जय श्री राम","जय श्री राम"]

angle = 360/49
penup()
sety(-1)
for i in range(50):
    left(angle)
    forward(260)
    write(Ram_naam[i], align="right",
    font=('Arial',12,"bold"))
    backward(260)


penup()    
goto(-40,-20)
pendown()
write("|| राम ||", font=("Arial", 60,"normal"), align="center")
hideturtle()
done()

 

Output:

Jai Shree Ram using Python Turtle

 

Explanation: 

In above code a simple Turtle graphics program that draws the words “जय श्री राम” in a circular pattern with the phrase “|| राम ||” at the center. Let’s break down the code in an easy way:

1. Setting Up Turtle:
from turtle import *: Imports the `turtle` module.

2. Setting Up the Drawing Environment:

-title(‘Jai Shree Ram’): Sets the title of the turtle window.

– bgcolor(‘blue’): Sets the background color to blue.

– pensize(6): Sets the pen size to 6 pixels.

– pencolor(“orange”): Sets the pen color to orange.

3. Creating a List of Text:

– Ram_naam: A list containing the phrase “जय श्री राम” repeated 49 times.

4. Drawing the Circular Pattern:

– angle = 360/49: Calculates the angle for each step in the circular pattern.

– Loop to draw the circular pattern:

– penup(): Lifts the pen.

– sety(-1): Sets the turtle’s y-coordinate slightly below the center.

– left(angle): Rotates the turtle to the left by the calculated angle.

– forward(260): Moves the turtle forward by 260 units (radius of the circle).

– write(Ram_naam[i], align=”right”, font=(‘Arial’, 12, “bold”)): Writes the text aligned to the right.

– backward(260): Moves the turtle backward to the starting position.

5. Drawing the Center Text:
penup(): Lifts the pen.
– goto(-40, -20): Moves the turtle to a specific position.
– pendown(): Lowers the pen.
– write(“|| राम ||”, font=(“Arial”, 60, “normal”), align=”center”): Writes the center text in a larger font and centered.

6. Finishing Touches:
– hideturtle(): Hides the turtle icon.
– done(): Finishes the drawing.

In simple terms, this program uses the Turtle graphics library to draw a circular pattern of the phrase “जय श्री राम” with a center message “|| राम ||” in a blue background. The colors and sizes can be adjusted to customize the appearance.

 

Here is another amazing program to draw/write RAM using python.

from turtle import *
from time import *
import numpy

title("RAM NAAM")
bgcolor("blue")
colormode(255)
speed(1)
sleep(2)

x= -200
y=200

def ram_name():
    c="orange"
    color(c)
    write("राम", font=("Arial", 
    12, "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:

Ram

 

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved