NOTE : Is learning \"Python programming\" DO \"YOUR PROGRAM\" , THE \"EXTRA CRED
ID: 3587971 • Letter: N
Question
NOTE: Is learning "Python programming"
DO "YOUR PROGRAM" , THE "EXTRA CREDIT CHALLENGE" IS UP TO YOU
Your Program Use Turtle Graphics to draw (not write!) your initials and an object that represents some- thing you enjoy. The object must be made up of at least three pieces, meaning the Turtle must draw at least three separate things to create the object. You could draw a flower, a castle, a tennis court, etc. You may not draw something that consists of only one shape, like a ball or a box. Extra Credit Challenges You can earn 5 extra points for each of the following features you include and successfully implement in your program . Allow the user to interact with the Turtle by using mouse events . Allow the user to control the Turtle by asking the user for input (such as asking how far to go, the dimensions of an object, or the RGB values for a color) . Use the Turtle's state (its position, distance, or heading) in an if statement to control how the Turtle behaves Program Requirements 1. You must use at least three different colors 2. You must use at least one loop (while or for) 3. You must define and use at least five functions to help create your drawing. You may not count draw rectangle and draw triangle towards the five, though you may use them in vour program 4. At least one of your functions must be used to compute something and return a value. For instance, you may need to calculate the length of a diagonal to move the turtle that far. 5. Every function must have a docstringExplanation / Answer
"""
please add indentation in the code below
it will be removed when i upload the code
"""
import turtle
import math
def line_t(temp, number, length, angle): #Draws n line segments.
for i in range(number):
temp.fd(length)
temp.lt(angle)
def polygon(temp, number, length): #Draws a polygon with n sides.
angle = 360/n
line_t(temp, number, length, angle)
def arc(temp, temp2, angle): #Draws an arc with the given radius and angle.
arc_length = 2 * math.pi * temp2 * abs(angle) / 360
n = int(arc_length / 4) + 1
step_len = arc_length / n
step_angle = float(angle) / n
temp.lt(step_angle/2)
line_t(temp, n, step_len, step_angle)
temp.rt(step_angle/2)
def petal(temp, temp2, angle): #Draws a petal using two arcs.
for i in range(2):
arc(temp, temp2, angle)
temp.lt(180-angle)
def leaf(temp, temp2, angle, p):#Draws a leaf and fill it.
temp.begin_fill()
temp.down()
flower(temp, 1, temp2, angle, p)
temp.end_fill()
def flower(temp, number, temp2, angle, pn): #Draws a flower with n petals.
for i in range(number):
petal(temp, temp2, angle)
temp.lt(pn/number)
def main():
window=turtle.Screen() #creating a window for flower
lucy=turtle.Turtle()
lucy.shape("turtle")
lucy.color("red")
lucy.width(5)
lucy.speed(0)
flower(lucy, 10, 40, 100, 360) #drawing a flower
lucy.color("brown") # Drawing stem
lucy.rt(90)
lucy.fd(200)
lucy.rt(270) # Drawing leaf
lucy.color("green")
leaf(lucy, 40, 80, 180)
lucy.ht()
window.exitonclick()
main()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.