Complete this week’s learning questions before undertaking this homework. Answers to the questions in this homework are to be typed directly into this document. This assignment is to be carried out individually
You will be handing in this Word document and two python (“py”) files.
Overview
This homework involves using a step-by-step process to write python scripts that use assignment statements to carry out calculations related to real-world problems. There are two problems—make sure to do them both, and to hand in your two python files along with this document. For each storyboard, you should have only one image per page, placed above the step number and description. Make sure to then add a page break before the next step and its associated image. Make sure that your images fill as much of the page as possible.
Problem 1: Painting a wall with a door and window
You want to paint a wall that has a door and a window. The wall is 15 feet wide by 10 feet high, the door is 3 feet wide by 7 feet high, and the window is 3 feet wide by 5 feet high. Paint is sold by the quart, where each quart covers 50 square feet. Write a python script to calculate how many quarts of paint you need to buy in order to paint the wall but not the door or window. In the pages that follow, please provide a screen snipping that shows that you are carrying out the writing of the script step by step. Each screen snipping should be taken after you have carried out what is described in the text below the snipping. I have done the first step for you.
Step 1. The image above is the calculation using a diagram. Note that since we do not want to paint the wall or door, we have to calculate their area separately, and subtract them from the area of the wall.
[Screen snipping here – and in this location for each step]
Step 2. Set up your desktop on your computer so that you are prepared to program. Open your Internet browser and navigate to PythonTutor. Start IDLE, which opens a new execution window. After you have done so, provide a screen snipping that shows both windows, similar to what I have in Step 2 of the storyboard in the “Using storyboards” document associated with this week’s learning questions assignment.
Step 3. In IDLE, go to the “File” menu and create a New File and save this as “paint_rectangular_surface2.py” in a directory that you can locate on your computer. After you have done so, provide a screen snipping that shows this file in a folder on your computer.
Step 4. In the editor window write a header, which includes your name as the author and a brief description of what the script does. Leave a blank line between the header and the start of your code. After you have done so, provide a screen snipping that shows these comments in your IDLE editor window. Make sure to include the frame of the IDLE editor window, so that I can actually tell that this is IDLE (and not some other code editor).
Step 5. Write assignment statements so that each numeric quantity in the diagram above that is not the result of a calculation is assigned to its own variable. These are the values 3, 7, 3, 5, 10, 15, and 50, for all of the rectangular dimensions and for the paint coverage in quarts. Make sure to name these variables so that these names follow all programming rules. After you have done so, provide a screen snipping that shows your entire IDLE editor window.
Step 6. Just to make sure that you on the right track, run the code that you have written so far in PythonTutor. Make sure to step through the code with the “Next” button, and check the memory (on the right-hand side) that there is a variable with the correct name for each of the variables defined in the python code on the left and that the values in these variables is equal to the right-hand side of each assignment statement in the python code on in the code execution window. If there are any errors, then fix your code to remove them. If you are unable to do so, then please contact me and I can help – provide your storyboard up to this step. After you have fixed all errors, provide a screen snipping above that shows both the code and the memory (the blue “Frames” box) from the execution window in PythonTutor after all lines of code have executed.
Step 7. Go back to your script in IDLE, and write the calculation instructions. From the calculation on the image in Step 1, use multiplication to determine the square feet of wall, window, and door area, and then subtract the window and door areas from the wall area. Finally, divide the square footage by the paint coverage in quarts to yield your final result. Make sure not to use any numbers directly in calculations but instead use the variables that hold these numbers. If there are any errors, then fix your code to remove them. If you are unable to do so, then please contact me and I can help – provide your storyboard so far. After you have fixed all errors, provide a screen snipping with all lines of code from your IDLE edit window.
Step 8. Copy, paste, and run this script in PythonTutor, checking the values in memory to make sure that the correct calculation has been carried out. If there are any errors, then fix your code to remove them. If you are unable to do so, then please contact me and I can help – provide your storyboard so far. After you have fixed all errors, provide a screen snipping above that shows both the code execution window and memory from the execution visualizer in PythonTutor after all lines of code have executed. When you have done this, move on to the next problem. Remember to upload the python script that you just completed and the one that you develop for the next problem, and this Word document in Canvas.
Problem 2: Soil for a gardening project
You and your neighbors want to start a community garden, and the city has donated three small plots of land of different shapes for this use. Write a python script to calculate how much soil you will need in total for all three plots. In the pages that follow, please provide a storyboard that shows that you are carrying out the writing of the script step by step. I have done the first step for you. Each page of the storyboard has a screen snipping, a step number, and a textual description that discusses the screen snipping. Your storyboard should have a minimum of 6 steps, though you are free to include more steps. Two of these steps should have a screen snipping of code and memory in the PythonTutor execution window at the end of executing the code that you have written up to and including that step (like steps 6 and 8 above). I recommend that you mirror the steps in the storyboard above. It is important that you place only one step’s description and image on a single page. That is, you should not have more than one step per page. You can do this by inserting a page break (using the Insert menu)after each step. If you are unsure of how to do this, please do an Internet search to learn how.
Step 1. The snipping above is the calculation on a diagram of the plots. Note that the soil depth is two feet. The calculation relies upon the formula for volume, which is the area of the plots times the depth of soil. The result is in cubic feet. I am using the float value 3.14 as an estimate for the value pi, which is what I also expect you to do. In addition, I have rounded my values to the nearest 1/10th. Your results in PythonTutor might be slightly different, since PythonTutor does not do this rounding.
[Put the remaining steps of your storyboard for developing this program on subsequent pages, one page per step]