
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:
- Hello World in 35 Programming Languages
- How to Scrape Data From Any Website with Python?
- Become Job Ready With Free Harvard Computer Science course: Enroll Now
- Free Python Certification course from Alison: Good for Resume
- Download 1000+ Projects, All B.Tech & Programming Notes, Job, Resume & Interview Guide, and More – Get Your Ultimate Programming Bundle!
- Udacity Giving Free Python Course: Here is how to Enroll
- Love Babbar’s Income Revealed
- Top 5 Websites to Learn Programming in 2024
- Python Internship for college students and freshers: Apply Here
- Microsoft Giving Free Python Course in 2023: Enroll Now
- Top 5 Free Python Courses on YouTube in 2024
- Complete Python Roadmap for Beginners in 2024
- New secrets to Earn money with Python in 2024
- Connect with HR Directly – Job Hack
- Google offering free Python course: Enroll Today
- What is an AI Tool?
- Google Internship 2024
- TCS Launched Free Certification Course with Industry Recognized Value
- Top Free AI Tools for Students and Job Seekers
- Unveiling the Future of AI Detector
- CodeWithHarry Earns 20 Lakhs per month from YouTube?
- Cleaning Service Booking System in Python Tkinter
- Farmers Ecommerce App using Python Tkinter
- Guidelines for Project Collaboration Process
- 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