
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.
Also Read:
- The system of the binary conversion
- What is web development for beginners?
- Guide to Proxy Servers: How They Work and Why You Need Them?
- Python | Check Armstrong Number using for loop
- Python | Factorial of a number using for loop
- Link in bio
- Microsoft Giving Free Machine Learning Course: Enroll Now
- Accenture Giving Free Developer Certificate in 2023
- Python | Asking the user for input until they give a valid response
- Python | How to iterate through two lists in parallel?
- Amazon Summer Internship 2023
- Python | How to sort a dictionary by value?
- Amazon Giving Free Machine Learning Course with Certificate: Enroll Now
- Google Summer Internship 2023
- Python | How to split a list into equally-sized chunks?
- 5 Secret ChatGPT skills to make money
- Python | Remove items from a list while iterating
- Free Google Certification Courses
- 5 AI tools for coders better than ChatGPT
- Python | How to get dictionary keys as a list
- New secrets to Earn money with Python in 2023
- Flower classification using CNN
- How to represent Enum in Python?
- 5 methods | Flatten a list of lists | Convert nested list into a single list in Python
- What does if __name__ == __main__ do in Python?
- Music Recommendation System in Machine Learning
- Brick Breaker Game in C++
- Dino Game in Java
- Java Games Code | Copy And Paste
- How to utilize ChatGPT to improve your coding skills?