Pythondex
Turtle Python Programs

Draw Virus Using Python Turtle With Code

Last updated June 12, 2023 by Jarvis Silva

In this tutorial we will see how to draw virus with python, We will use the turtle module to draw this virus, Turtle is a GUI library with the help of this library you can draw anything in python. 

Python Code To Draw Virus


import turtle as t

t.speed(10)
t.color('yellow')
t.bgcolor('black')
b = 200 

while b > 0:
 	t.left(b)
 	t.forward(b * 3)
 	b = b - 1

t.done()

Above is the python code for drawing the virus, below is a simple explaination of how this code works:

  • Import the turtle module and rename it as ‘t’.
  • Set the drawing speed of the turtle to 10.
  • Set the pen color to yellow and the background color to black.
  • Set the variable ‘b’ to 200.
  • Enter a while loop that continues until ‘b’ becomes 0.
  • Inside the loop, turn the turtle left by the value of ‘b’ degrees.
  • Move the turtle forward by ‘b’ multiplied by 3 units.
  • Decrement the value of ‘b’ by 1.
  • Repeat steps 6-8 until ‘b’ reaches 0.

Now to run this program you need to have python installed on your computer, If you don’t have then follow this guide: Install and setup python on your computer or use this online python compiler.

After you run the program it will open a new window and it will start drawing Virus and below is the finished drawing.

Virus Drawing In Python

As you can see, we successfully drew a virus, I hope you found this program helpful and useful, do share it with your friends who are intrested in programs like this. 

Here are some more python drawing tutorials for you:

I hope you found what you were looking for from this tutorial, and if you want more python guides and tutorials like this, do join our Telegram channel for future updates.

Thanks for reading, have a nice day 🙂