Python Turtle Design of Circle Mania

Python Turtle Design of Circle Mania

In this article, we will be learning about a very cool Python Turtle Design of Circle Mania. The code for the turtle program is given below. Accordingly, this article will explain to you how you can code in turtle that will allow you to create a circle mania. We will first see the code and then, we will understand it line-by-line. Now let’s see the code for design.


Code:


import turtle

wn = turtle.Screen()
wn.bgcolor('black')
s = turtle.Turtle()
s.speed('fastest')
s.color('white')
rotate = int(180)


def Circles(t, size):
    for i in range(10):
        t.circle(size)
        size = size - 4


def ankur(t, size, repeat):
    for i in range(repeat):
        Circles(t, size)
        t.right(360 / repeat)


ankur(s, 200, 10)

t1 = turtle.Turtle()
t1.speed(0)
t1.color('yellow')
rotate = int(90)


def Circles(t, size):
    for i in range(4):
        t.circle(size)
        size = size - 10


def ankur(t, size, repeat):
    for i in range(repeat):
        Circles(t, size)
        t.right(360 / repeat)


ankur(t1, 160, 10)

t2 = turtle.Turtle()
t2.speed(0)
t2.color('blue')
rotate = int(80)


def Circles(t, size):
    for i in range(4):
        t.circle(size)
        size = size - 5


def ankur(t, size, repeat):
    for i in range(repeat):
        Circles(t, size)
        t.right(360 / repeat)


ankur(t2, 120, 10)

t3 = turtle.Turtle()
t3.speed(0)
t3.color('red')
rotate = int(90)


def Circles(t, size):
    for i in range(4):
        t.circle(size)
        size = size - 19


def ankur(t, size, repeat):
    for i in range(repeat):
        Circles(t, size)
        t.right(360 / repeat)


ankur(t3, 80, 10)

t4 = turtle.Turtle()
t4.speed(0)
t4.color('cyan')
rotate = int(90)


def Circles(t, size):
    for i in range(4):
        t.circle(size)
        size = size - 20


def ankur(t, size, repeat):
    for i in range(repeat):
        Circles(t, size)
        t.right(360 / repeat)


ankur(t4, 40, 10)
turtle.done()


Explanation:


  • First, we should import turtle, math, and random modules.
  • Secondly, the turtle screen is started and the background color is set to black.
  • The speed is set to the fastest possible and the color of the pen is white. The rotate variable is set to 180.
  • Thirdly, a function name Circle() with the parameters of t and size is written.
  • Here, a for loop is repeated 10 times where the size is set. Fourth, a function namely ankur() with the parameters t, size, and repeat is written.
  • Here, a for loop is written which repeats itself according to the argument of the repeat parameter.
  • Then another portion called t1 is drawn where the speed is 0 and the color is yellow.
  • After the ankur() function is called with the arguments s, 200, and 10 the first circle starts drawing.
  • Here, the rotate variable is set to 90.
  • Fifth, another function named the circle() with the parameter t and size.
  • Here, a loop is written which repeats itself 4 times.
  • This has the t portion’s size. Again, another function namely ankur() with the parameter t, size, and repeat is written and has the same as above.
  • Now, again ankur() function is called with the arguments t1, 160, and 10where the circles are drawn.
  • Seventh, the t2 variable is set to the turtle screen and the speed is 0 whereas the color is set to blue.
  • Here the rotate variable is set to 80. Then the process goes on with the change in the arguments and the tS increases every once.

Output:


Video output:



Image Output:




Run Now:



Comment your queries or anything you want to know or tell us based on this post or website.

Thanks for reading


Also read:


Python Turtle Side Look Emoji

Python Turtle Beautiful Design

Guess the Number Python

Snake Game in Python using Pygame

Rock Paper Scissor Game Using Python Tkinter

Password Generator Application In Python


Share:

Author: Ayush Purawr