# Draw Virus using Python Turtle ## Introduction

Hello everyone, welcome to copyassignment.com. In this article, we are learning to draw Virus using Python Turtle module. It’s a simple, cool, and easy python project for beginners learning the python turtle. We are providing the source code along with the output for your reference. We are also providing a detailed explanation for the code.

So let’s start to draw a vibrating circle.

### Import Turtle

`import turtle`

Import function imports the turtle module for the project to access its methods and functions.

### Initialize the turtle object to access the Turtle functions

```tt=turtle.Turtle()
turtle.bgcolor("gray")
tt.pencolor("black")

tt.speed(0)
tt.penup()
tt.goto(0,200)
tt.pendown()
```

Here we are initializing our turtle object as tt. The background color is set to gray and the pencolor of the turtle is set to black. The speed of the turtle is initialized to 0. The position of the turtle is initialized to goto(0,200).

Penup() – Turtle doesn’t draw anything

Pendown()- Turtle begins drawing

### Function for drawing a Vibrating Circle

```#initialized the variables to zero
forDis=0
dR=0

while(True):
tt.forward(forDis)
tt.right(dR)
forDis+=3
dR+=1
if dR==210:
break
tt.hideturtle()

turtle.done()
```

In this block of code, we are writing the function for drawing the vibrating circle. Here we have initialized the forDis(forward Distance) and dR(distance Right)   variables to 0.

In the while loop, the condition is true, but the turtle will move forward distance set for forDis i.e after each iteration the forDis variable increases by 3. The turtle will move forward accordingly.

Similarly, the right angle variable dR is increased by 1 after each iteration.

In this, if the right angles i.e dR(distance Right) value becomes 210 then the loop will break. Hence the execution of the loop for the vibrating circle stops here and we get our desired output.

## Complete Code to Draw Virus using Python Turtle

```#Import Turtle
import turtle

tt=turtle.Turtle()
turtle.bgcolor("gray")#Screen background color set to gray
tt.pencolor("black")#Pencolor set to black

tt.speed(0)
tt.penup()
tt.goto(0,200)#position of the turtle
tt.pendown()

#Intialization of variables
forDis=0
dR=0

while(True):
tt.forward(forDis)
tt.right(dR)
forDis+=3 # forDis increased by 3 on every iteration
dR+=1# right angle distance increased by 1 on every iteration
#If the distance for right angle becomes 210 the loop breaks
if dR==210:
break
#Hide the turtle on completion of loop
tt.hideturtle()

#Completion of Turtle execution
turtle.done()```

## Output

Thank you for reading the article. 