Python Program to draw Indian flag 🇮🇳



Python program to draw Indian flag
@theschoolprogrammer


Hey there! coders

Today we are going write a code in Python programming language which will draw Indian flag. In this code we have used Turtle module. Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon in 1967.



Join Us

For those who prefer reading on mobile, we have Telegram channel and WhatsApp group that will allow you to receive updates, announcements, and links to our stories straight to your mobile device..



Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from turtle import *
# optional:shape("turtle")
speed(5)
setup(800, 500)

penup()
goto(-400, 250)
pendown()

# Orange Rectangle
color("orange")
begin_fill()
forward(800)
right(90)
forward(167)
right(90)
forward(800)
end_fill()

left(90)
forward(167)

# Green Rectangle
color("green")
begin_fill()
forward(167)
left(90)
forward(800)
left(90)
forward(167)
end_fill()

# Big Blue Circle
speed(5)
penup()
goto(70, 0)
pendown()
color("navy")
#code downloaded from www.theschoolprogrammer.com
begin_fill()
circle(70)
end_fill()

# Big White Circle
penup()
goto(60, 0)
pendown()
color("white")
begin_fill()
circle(60)
end_fill()

# Mini Blue Circles
speed(0)
penup()
goto(-57, -8)
pendown()
color("navy")
for i in range(24):
    begin_fill()
    circle(3)
    end_fill()
    penup()
    forward(15)
    right(15)
    pendown()

# Small Blue Circle
speed(5)
penup()
goto(20, 0)
pendown()
begin_fill()
circle(20)
end_fill()

# Spokes
penup()
goto(0, 0)
pendown()
pensize(2)
for i in range(24):
    forward(60)
    backward(60)
    left(15)
    
hideturtle()

Output:


Found this useful? Share with your friends. Share

Also check:

Comments

You are welcome to share your ideas with us in comments!!!

Full Screen Mode

Archive

Contact Form

Send