Draw Corona Virus With Python
Draw a picture of the Corona virus using Python Turtle Graphics
Tuesday, March 17, 2020
This Blog is a Little Silly
This blog is a little silly. It explains how to draw the Corona Virus using Python and turtle graphics.
What's included:
1) How to install Python
2) Short explanation of Python Turtle Graphics
3) Draw the Corona Virus in three easy steps (working Python programs)
Enjoy!
Installing Python
In order to install Python on your computer, do the following:
1) Go to python.org.
2) Select Downloads.
3) Download latest version.
4) Install. When you get the screen above, also check the second box.
5) Done.
6) I suggest for the first little while to work with IDLE that was also installed with Python.
7) In case of doubt, look for a tutorial, there are plenty!
Also, check the video below:
Turtle Graphics in Python
# It turns out that it's really easy to have a turtle that draws in Python.
# For example, the program below draws the star above:
from turtle import * color('red', 'yellow') begin_fill() while True: forward(200) left(170) if abs(pos()) < 1: break end_fill() done()
# For drawing the image below, you will have to work a little harder :)
Monday, March 16, 2020
Phase 1
# In this phase we draw one knob using turtle graphics:
import turtle
t=turtle.Turtle()
t.color('red', 'yellow')
t.begin_fill()
t.lt(90)
t.fd(60)
t.lt(90)
t.fd(60)
t.rt(90)
t.fd(60)
t.rt(90)
t.fd(180)
t.rt(90)
t.fd(60)
t.rt(90)
t.fd(60)
t.lt(90)
t.fd(60)
t.rt(90)
t.fd(62)
t.end_fill()
turtle.done()
Phase 2
#In this phase we draw 8 knobs in a line:
import turtle
t=turtle.Turtle()
t.color('red', 'yellow')
def blita():
t.begin_fill()
t.lt(90)
t.fd(30)
t.lt(90)
t.fd(30)
t.rt(90)
t.fd(30)
t.rt(90)
t.fd(90)
t.rt(90)
t.fd(30)
t.rt(90)
t.fd(30)
t.lt(90)
t.fd(30)
t.rt(90)
t.fd(30)
t.lt(180)
t.end_fill()
t.pu()
t.fd(400)
t.pd()
blita()
for i in range (7):
t.pu()
t.fd(-120)
t.pd()
blita()
turtle.done()
Phase 3
#In this phase we draw 12 knobs on a circular virus:
import turtle
t=turtle.Turtle()
t.color('red', 'yellow')
t.pensize(6)
t.speed(10)
def blita():
t.begin_fill()
t.rt(90)
t.fd(50)
t.lt(90)
t.fd(50)
t.rt(90)
t.fd(50)
t.rt(90)
t.fd(150)
t.rt(90)
t.fd(50)
t.rt(90)
t.fd(50)
t.lt(90)
t.fd(50)
t.rt(90)
t.fd(50)
t.end_fill()
t.pu()
t.sety(-397)
t.pd()
for i in range(12):
t.circle(400,30)
blita()
t.begin_fill()
t.circle(400)
t.end_fill()
turtle.done()
Subscribe to:
Posts (Atom)