American Flag Python Project Academic Essay

Paper , Order, or Assignment Requirements

  • This project explores the use of procedures / sub-programs and python.
  • You will use the ‘turtle’ module in python to to create procedures (subprograms) that draw two pictures. The turtle module is describe in the python API reference but also in this online text: Hello Turtles
  • The first procedure draws an American flag with 50 stars and 13 stripes, where the width of the flag is a parameter to the function. The specifications for the flag are described at http://www.usflag.org/flag.specs.html. Your solution should break the problem down into several subprograms; for example you should have a procedure to draw a star. You are free to break the problem of drawing the flag down into additional subprograms as you see fit, but I expect a rationale for the breakdown in the writeup. You may use non-standard colors for the flag if you like; but I expect the geometry to match the specification.
  • The second is any picture of your choosing; but it must include at least one American flag.
  • You must submit a writeup formatted as a PDF for this assignment. The writeup should include the following:
  • You must include an image of your flag
  • You must include your own custom image.
  • You must list all of the procedure names and parameters, along with a textual description of what the procedures accomplish and how they are used.
  • You must include the entire text of your python program (indented properly, in courier). You may put your code in a reduced font size (no smaller than 8 points). If you cannot fit your code in the width of a page, consider reformatting your code or breaking it up into smaller procedures. Note that in Pycharm you can copy and paste code into most word processors and it will preserve the formatting of the code quite well. At 8 points it the guidelines in Pycharm fit on the page.
  • Here is some code to get you started on drawing a star, since the geometry involved is a bit challenging:

import turtle
from math import sqrt

#Create a ‘turtle’ that can draw graphical shapes
t = turtle.Turtle()

#This is the size of the star
radius = 100

#draw a circle to test coordinates
# -> position turtle at bottom-center of circle
t.penup()
t.right(90)
t.forward(radius)
t.left(90)

#  -> draw circle
t.pendown()
t.circle(radius)

#  -> go back to center
t.penup()
t.left(90)
t.forward(radius)
t.right(90)

# In order to draw a star, I need to figure out the length of one ‘leg’ of the star.
# This took a diagram and bit of trigonometry to figure out …
leg = radius * sqrt(5-2*sqrt(5))

#Go to top of star, and point the turtle down the first leg of the star
t.penup()
t.left(90)
t.forward(radius)
t.right(162)

#Draw the star, starting at the top
t.begin_fill()
t.fillcolor(‘yellow’)
t.pendown()
for i in range(5):
t.forward(leg)
t.left(72)
t.forward(leg)
t.right(144)
t.end_fill()

# Return to initial location
t.penup()
t.right(18)
t.forward(radius)
t.left(90)

Is this question part of your Assignment?

We can help

Our aim is to help you get A+ grades on your Coursework.

We handle assignments in a multiplicity of subject areas including Admission Essays, General Essays, Case Studies, Coursework, Dissertations, Editing, Research Papers, and Research proposals

Header Button Label: Get Started NowGet Started Header Button Label: View writing samplesView writing samples