In Part 1, you will write the functions to draw a figure that will look the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In Part 1, you will write the functions to draw a figure that will look the figure below. The only difference is it will display your initials instead of WG. The steps to do this our detailed below. 1. Import the turtle module. 2. Write a function called draw_filled square. It will take three (3) parameters: a turtle, the size of the square, and a color. The function header will look like the following: def draw filled square(turtle, size, color): 3. In the draw filled square function body do the following: a. Invoke the turtle's fillcolor function, to set the fill color to the color that was passed to the function. b. Turn the fill on for the turtle using the turtle's begin fill function. c. Draw a square of the size specified via the size parameter using a for loop. d. Turn the fill off using the turtle's end fill function. 4. Write a function called draw_picture that will not take any parameters. In this function do the following: a. Create the screen. b. Create the turtle. c. Draw the four boxes alternating the blue and green colors as depicted above. Remember to call the draw_filled square you wrote in Steps 2 and 3 above. i. The boxes should be of size 300 and centered at (0, 0). 5. Save and run the program to verify the four boxes are drawn. Do not move on until they are drawn correctly. 6. Refactor the code and move the code that draws the four boxes into a function called perform boxtrot. This function will need to take one parameter which is a turtle. The function header will be: def perform boxtrot(turtle): a. When you move this code, make sure you replace the name of the turtle with the name of the turtle parameter. 7. In the draw picture function add a call to perform boxtrot and pass it the turtle that was created in the draw picture function. 8. Save and run the program to verify the four boxes are still drawn. Do not move on until they are drawn correctly. Part 1 - Drawing initials Next, you will write the code to draw your first and last initial, e.g., if your name is Bob White, you will write code to draw a B and W. 1. In the draw picture function, after the call to perform boxtrot add a call to a function named draw first initial and pass it the name of the turtle that was created in the draw picture function. 2. Add a new function called draw first initial that takes one parameter which is a turtle. The function header will be: def draw first initial(turtle): 3. In the draw first initial function body, add code to draw your first initial in the upper-left corner box. 4. Save and run the program to verify the four boxes are still drawn and it draws your first initial in the upper-left box. 5. In the draw picture function, after the call to draw first initial add a call to a function named draw last initial and pass it the name of the turtle that was created in the draw picture function. 6. Add a new function called draw last initial that takes one parameter which is a turtle. The function header will be: def draw last initial(turtle): 7. In the draw last initial function body, add code to draw your last initial in the lower-right corner box. 8. Save and run the program to verify the four boxes are still drawn and it draws your first and last initial in the correct locations. 9. This completes the requirements for Part 1 of the project, so add a comment at the top of the file that states you: Successfully completed Part 1 of the project. If you didn't complete all of Part 1, then in the comment state what you did complete. 10. I would encourage you to upload what you have completed to Course Den. I would also suggest keeping a backup of this file. 11. If you successfully completed all of Part 1 and you so desire, you may proceed onto Part 2 of the project. Part 2 will not be as detailed as the step-by-step specifications for Part 1 were. The requirements will be given and you will need to figure out how to implement them. In Part 2, you will create a second turtle whose responsibility is to draw a matte and border of made out of triangles. An example of the resulting figure is depicted below: W G 1. In the draw_picture function create a second turtle object. 2. Use the second turtle object to draw the gray matte around the initialed box trot. a. Hint: Think about drawing the matte first. 3. If need be, refactor the code and extract this gray matte drawing out to its own function and call that function within the draw picture method. 4. Add functionality to create the triangle frame border depicted above. This border must be drawn using the second turtle you created. a. Make sure your code adheres to the Single Responsibility (SRP) and Don't Repeat Yourself (DRY) principles. 12. This completes the requirements for Part 2 of the project, so add a comment at the top of the file that states you: Also, successfully completed Part 2 of the project. If you didn't complete all of Part 2, then in the comment state what you did complete. In Part 1, you will write the functions to draw a figure that will look the figure below. The only difference is it will display your initials instead of WG. The steps to do this our detailed below. 1. Import the turtle module. 2. Write a function called draw_filled square. It will take three (3) parameters: a turtle, the size of the square, and a color. The function header will look like the following: def draw filled square(turtle, size, color): 3. In the draw filled square function body do the following: a. Invoke the turtle's fillcolor function, to set the fill color to the color that was passed to the function. b. Turn the fill on for the turtle using the turtle's begin fill function. c. Draw a square of the size specified via the size parameter using a for loop. d. Turn the fill off using the turtle's end fill function. 4. Write a function called draw_picture that will not take any parameters. In this function do the following: a. Create the screen. b. Create the turtle. c. Draw the four boxes alternating the blue and green colors as depicted above. Remember to call the draw_filled square you wrote in Steps 2 and 3 above. i. The boxes should be of size 300 and centered at (0, 0). 5. Save and run the program to verify the four boxes are drawn. Do not move on until they are drawn correctly. 6. Refactor the code and move the code that draws the four boxes into a function called perform boxtrot. This function will need to take one parameter which is a turtle. The function header will be: def perform boxtrot(turtle): a. When you move this code, make sure you replace the name of the turtle with the name of the turtle parameter. 7. In the draw picture function add a call to perform boxtrot and pass it the turtle that was created in the draw picture function. 8. Save and run the program to verify the four boxes are still drawn. Do not move on until they are drawn correctly. Part 1 - Drawing initials Next, you will write the code to draw your first and last initial, e.g., if your name is Bob White, you will write code to draw a B and W. 1. In the draw picture function, after the call to perform boxtrot add a call to a function named draw first initial and pass it the name of the turtle that was created in the draw picture function. 2. Add a new function called draw first initial that takes one parameter which is a turtle. The function header will be: def draw first initial(turtle): 3. In the draw first initial function body, add code to draw your first initial in the upper-left corner box. 4. Save and run the program to verify the four boxes are still drawn and it draws your first initial in the upper-left box. 5. In the draw picture function, after the call to draw first initial add a call to a function named draw last initial and pass it the name of the turtle that was created in the draw picture function. 6. Add a new function called draw last initial that takes one parameter which is a turtle. The function header will be: def draw last initial(turtle): 7. In the draw last initial function body, add code to draw your last initial in the lower-right corner box. 8. Save and run the program to verify the four boxes are still drawn and it draws your first and last initial in the correct locations. 9. This completes the requirements for Part 1 of the project, so add a comment at the top of the file that states you: Successfully completed Part 1 of the project. If you didn't complete all of Part 1, then in the comment state what you did complete. 10. I would encourage you to upload what you have completed to Course Den. I would also suggest keeping a backup of this file. 11. If you successfully completed all of Part 1 and you so desire, you may proceed onto Part 2 of the project. Part 2 will not be as detailed as the step-by-step specifications for Part 1 were. The requirements will be given and you will need to figure out how to implement them. In Part 2, you will create a second turtle whose responsibility is to draw a matte and border of made out of triangles. An example of the resulting figure is depicted below: W G 1. In the draw_picture function create a second turtle object. 2. Use the second turtle object to draw the gray matte around the initialed box trot. a. Hint: Think about drawing the matte first. 3. If need be, refactor the code and extract this gray matte drawing out to its own function and call that function within the draw picture method. 4. Add functionality to create the triangle frame border depicted above. This border must be drawn using the second turtle you created. a. Make sure your code adheres to the Single Responsibility (SRP) and Don't Repeat Yourself (DRY) principles. 12. This completes the requirements for Part 2 of the project, so add a comment at the top of the file that states you: Also, successfully completed Part 2 of the project. If you didn't complete all of Part 2, then in the comment state what you did complete.
Expert Answer:
Related Book For
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba
Posted Date:
Students also viewed these programming questions
-
Ravsten Company uses a job-order costing system. On January 1, the beginning of the current year, the company's Inventory balances were as follows: Raw materials Work in process Finished goods...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
"Don't tell me we've lost another bid!" exclaimed Janice Hudson, president of Prime Products Inc. "I'm afraid so, replied Doug Martin, the operations vice president. "One of our competitors underbid...
-
The preparation of an organization's budget: a. forces management to look ahead and try to see the future of the organization. b. requires that the entire management team work together to make and...
-
A closed tank, V = 10 L, containing 5 kg of water initially at 25C, is heated to 175C by a heat pump that is receiving heat from the surroundings at 25C. Assume that this process is reversible. Find...
-
Nowhere Man Corporation is a corporate dance studio. It is a popular investment with investors between the ages of 20 and 30. Nowhere Man has a dilemma. It needs money to expand its business to cash...
-
With reference to the previous exercise, construct a 90% confidence interval for the true population mean quantity of gravel in concrete mixes. Data From Previous Exercise 7.1 A construction engineer...
-
The following sample data reflect shipments received by a large firm from three different vendors. a. Specify the competing hypotheses to determine whether quality is associated with the source of...
-
Head-First Company plans to sell 5,120 bicycle helmets at $74 each in the coming year. Unit variable cost is $45 (includes direct materials, direct labor, variable factory overhead, and variable...
-
Ellen considered saving $10,000 per year for her retirement. Although $10,000 is the most she can save in the first year, she expects her salary to increase each year so that she will be able to...
-
Perform the arithmetic operations given below. Pay careful attention to the order of operations and whether the result is an int (like 3) or double (like 3.0). You can earn partial credit for an...
-
Dividend policies for any Small, Mid, Large cap company during COVID in India. Give an example for each and explain in detail.
-
Joey Chestnut, the hot dog competitive eating champion, sees all of these ads for home workout machines. He is disappointed because his gyms - restaurants - aren't open so he cannot work out. Thus,...
-
What will happen if Stock market turnover decreases? State 3 points about the question. Your answers should be related to the stock market during covid-19.
-
Critically discuss the use of derivative instruments within firms and how these can be used in order to mitigate financial risks. Provide examples to support your answers.
-
Analyze the time value of money. Give an example of the future value of installment payments, present value of installment payments. Examine Perpetuity. Give an example of the perpetuity.
-
A ray of light falls perpendicular to face AB of a prism whose cross section is an isosceles rectangle. The ray follows the path shown in the figure. About the refractive index of the prism material...
-
Evaluate the function at the given value(s) of the independent variable. Simplify the results. (x) = cos 2x (a) (0) (b) (- /4) (c) (/3) (d) ()
-
In this exercise, we are working with the concept of an elasticity of substitution. This concept was introduced in part B of the Chapter. Thus, this entire question relates to material from part B,...
-
One of the most famous games treated in early game theory courses is known as the Battle of the Sexes and it bears close resemblance to the game in which you and I choose sides of the street when...
-
I express my undying love for my wife through weekly purchases of roses that cost $5 each. A. Suppose you have known me for a long time and you have seen my economic circumstances change with time....
-
Discuss various contexts where you can apply this pattern.
-
What are some of the anticipated problems that are likely to emerge while designing change pattern.
-
Define some major and minor research issues of this chapter.
Study smarter with the SolutionInn App