Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Part 1, you will write the functions to draw a figure that will look the figure below. The only difference is it will

In Part 1, you will write the functions to draw a figure that will look the figure below. The only difference 6. Refactor the code and move the code that draws the four boxes into a function called perform boxtrot. This 8. Save and run the program to verify the four boxes are still drawn and it draws your first and last initial 3. If need be, refactor the code and extract this gray matte drawing out to its own function and call that

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Primary ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Programming questions