# functions in python | Browse Homework

PreparationDownload and run the program PracticeFunctions.py. Download PracticeFunctions.py.Look at what it does and look at the code to get an idea of the program structure.
DirectionsThe programming assignment for this unit has two functions. Use these two functions as models for the functions you are to write. You will be removing code from main() and putting it in several separate functions. The behavior of the program will not change throughout the exercise, so you can always tell if your program is correct. As you copy code from the main to a function, you will have to change the name of variables to match the names of the function parameters.
Use the non-fruitful function drawRect as a model. Write another non-fruitful function that draws a filled circle. The function is defined as
“”” Draws a filled circle of radius rad using turtle t “””and called with a statement likedrawFilledCircle(alex, radius)The contents of the function are to begin filling, draw a circle, end filling.Make sure you call your function in two different places in the program, using a different parameter each time.
Write another non-fruitful function drawEquilateralTriangle , which is defined asdef drawEquilateralTriangle(t, side):
“”” Draws an equilateral triangle using turtle t with sides of length side “””
and is called withdrawEquilateralTriangle(alex, tri_side)Make sure to use the parameters side in the body of this function. Make sure you call your function in two different places in the program, using a different parameter each time.
Next, you’ll work with fruitful functions. Look at the function to calculate the next y-position for drawing a set of shapes. This function is called near the bottom of the program:ypos = next_y_position(ypos, width)Using this function as a model, add a fruitful function to calculate the length of a side of an equilateral triangle with a given area, which is math.sqrt(length*width*4/math.sqrt(3)). The function is defined withdef getSide(len,wid):
“”” Returns the length of a triangle side with an area of len * wid “”” and it is called with the statementtri_side = getSide(length,width)Make sure you use the parameters len and wid in the body of the function.
Again, using this function as a model, add a fruitful function to calculate the value math.sqrt(length*width/math.pi)which appears near the end of the program. The function should be defined asdef getRad(len,wid): “”” Returns the radius of a circle with an area of len * wid “”” and it is called with the statementradius = getRad(length,width)Make sure you use the parameters len and wid in the body of the function.
Make sure your functions have the same parameters and the same comment as in the assignment description. Write a complete header comment.
Create your own function and call it from main. Your function doesn’t have to do a lot, but it does have to do something.
SubmissionSubmit the file with .py extension.
Write a reflection in the comment box answering the following questions:
Describe the new function you added. Give its name.
In a sentence or two, what did you learn?
In a sentence or two, what did you find confusing or would like to see done differently regarding this project?
In a sentence or two, if you had another hour or two, what would you like to add to the project or how would you do things differently?

Don't use plagiarized sources. Get Your Custom Essay on
functions in python | Browse Homework
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT! To Get a 10% Discount Use Coupon Code FIRST39420
Calculator

Total price:\$26
Our features