Question: code in python please # draws a tree import turtle # set the canvas window def set_canvas(): s = turtle.Screen() s.setup(450, 410) s.bgcolor('ivory') s.title('Turtle Program')

code in python please

code in python please # draws a tree import turtle # setthe canvas window def set_canvas(): s = turtle.Screen() s.setup(450, 410) s.bgcolor('ivory') s.title('Turtle

# draws a tree import turtle # set the canvas window def set_canvas(): s = turtle.Screen() s.setup(450, 410) s.bgcolor('ivory') s.title('Turtle Program') return s # set a turtle (a pen) def set_pen(color): t = turtle.Turtle() t.shape('turtle') t.pen(pencolor=color,fillcolor=color, pensize=1, speed=10) return t # draw a tree fractal using recursion def draw_tree(t, branch, angle, n): if n > 0: # recursive step pass else: # base case pass # main program if __name__ == '__main__': s = set_canvas() t = set_pen('brown') t.penup() t.goto(-45, -150) t.left(90) t.pendown() draw_tree(t, 60, 20, 6)

Problem 1. Regular Polygons (5 points) Write a program named polygons.py that has two functions for generating convex regular polygons Regular poly.gon - Wikipedia . . One function should be implemented using an iteration (a for loop), and another function should be a recursion. It is optional to fill in your shapes. The functions for generating polygons should be named polygon (size, n ) and polygon_recursive(size, n, alpha) where size is the size of the polygon side (edge), n is the number of sides (or angles), and alpha is the angle of rotation. Problem 2. Star Polygons (5 points) Write a program named stars.py that has two functions for generating star polygons. One function should be implemented using an iteration (a for loop), and another function should be a recursion. It is optional to fill in your shapes. The functions for generating stars should be named star (size, n,d=2 ) and star_recursive (size, n, alpha, d=2 ), where size is the size of the polygon side You can read about star polygons here: Problem 2. Tree Fractal (5 points) A tree fractal is usually the first fractal to be learned. It is generated by recursively dividing a stem into two branches right and left and recursively drawing them. Complete the function draw_tree(t, branch, angle, n ) shown below. Please make sure that your function works with the provided code. Please name your file tree_fractal.py. Problem 1. Regular Polygons (5 points) Write a program named polygons.py that has two functions for generating convex regular polygons Regular poly.gon - Wikipedia . . One function should be implemented using an iteration (a for loop), and another function should be a recursion. It is optional to fill in your shapes. The functions for generating polygons should be named polygon (size, n ) and polygon_recursive(size, n, alpha) where size is the size of the polygon side (edge), n is the number of sides (or angles), and alpha is the angle of rotation. Problem 2. Star Polygons (5 points) Write a program named stars.py that has two functions for generating star polygons. One function should be implemented using an iteration (a for loop), and another function should be a recursion. It is optional to fill in your shapes. The functions for generating stars should be named star (size, n,d=2 ) and star_recursive (size, n, alpha, d=2 ), where size is the size of the polygon side You can read about star polygons here: Problem 2. Tree Fractal (5 points) A tree fractal is usually the first fractal to be learned. It is generated by recursively dividing a stem into two branches right and left and recursively drawing them. Complete the function draw_tree(t, branch, angle, n ) shown below. Please make sure that your function works with the provided code. Please name your file tree_fractal.py

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!