HW9 (due Sat. 4-Nov, 8pm)
Important Notes:
- Style Grading! We may grade your code for style. Be sure to review CS Academy section 2.3.1 for style guidelines. The checklist in 2.3.1 will be particularly useful as you complete your homework.
- Do not use any material not yet covered in weeks 1-9.
Each problem listed below is required. The point values they are worth are shown here in parentheses like this: (2).
Total points: 14pts
Note: The last problem is
not in CS Academy, and has its own submission process. Don't forget to submit this!
- Unit 7: Recursion
- 7.4 More Recursion Practice
- oddCount (1)
- oddSum (1)
- oddValues (1)
- oddMax (1)
- interleave (1)
- 7.8 Guided Exercises
- 7.9 Section Exercises
- hasRepeatedDigit (1)
- hasSublistSum (2)
- 7.10.3 Honors Exercises
- Required Task 1: Creative Fractal (2)
- For this exercise, you must write your code in VS Code, outside of CS Academy. Your file should be named with your andrewID + "_fractal.py" (for example, "mdtaylor_fractal.py").
- Your file should import cmu_graphics and should draw a fractal using recursive function calls, similar to how you drew 7.10.3 Teddy Bear Fractal (and in fact, you might want to copy and modify the functions you wrote for that exercise).
- In order to receive credit, your fractal must meet the following requirements:
- Your drawFractal function must make at least two calls to itself every time it reaches its recursive case. Each level should draw progressively smaller shapes. Do not hard-code the graphics for different recursion levels.
- Your level 0 fractal should draw at least six shapes and should use at least 3 colors.
- You may not import any modules aside from cmu_graphics (and math and/or copy, if you wish).
- As with the bear fractal, you must be able to increase and decrease the level of your fractal using the arrow keys.
- Your code should be able to draw a fractal at recursion level 5 without becoming unresponsively slow. It must not crash as the user changes the recursion levels. Note: If necessary you may increase the cmu_graphics 2000-shape limit by including
app.setMaxShapeCount(n)
, but don't set this so high that your application becomes unbearably sluggish.
- Your code must read in a file named
setup.txt
.
- This first line of this file will be the text of the title that you should display at the top of your canvas.
- The second line of this fill will be an integer of the fractal level that or app should start in (before users press any arrow keys)
- When grading, we'll modify the contents of this file. You can assume the file will be in the same folder as your Python file.
- You can use the following code to read in this file:
filename = 'setup.txt'
with open(filename, encoding='utf-8') as f:
fileString = f.read()
print(fileString)
- The fractal below meets the bear minimum requirements for this exercise (assuming this setup.txt file), though we hope you will use your creativity to try a new fractal pattern. Note: It does not have to resemble an animal as long as it's interesting!
- Your code should run in VS Code by pressing ctrl+B (cmd+B on Mac) when your Python file is open (and setup.txt is in the same folder as your Python file).
- Once you are done with your fractal, you must submit your Python file before the deadline to Canvas assignment Homework 9 Fractal.
Additional Notes:
- Each CS Academy assignment will show required "stars" in exercise sections, listed like this:
"Section Exercises: ⭐ 0 / 0."
Ignore these numbers. For this class they have no meaning. You must complete the problems described above.
- Do not hardcode to the test cases in your solutions.
From the syllabus:
Homework assignments will be primarily completed on the
CMU CS Academy website with few exceptions. These assignments will include code tracing exercises and free response exercises requiring writing code, which are all generally autograded. The homework allows you to get practice on solving problems in an untimed environment with unlimited tries to automatically check solutions in CS Academy. The lowest two homework grades will be half-weighted.
Homeworks are
entirely solo unless the assignment very explicitly allows you to collaborate. See the "Academic Integrity" section below for more details. That said, you always have access to extensive help provided by the TAs and course faculty. To get help on the homework assignments, you can go to daily office hours and/or post questions to Piazza.
A green checkmark next to a problem means it has autograded correctly and you are done. No green checkmark means it's not done yet. If you believe you should have received a green checkmark, be sure to review your work, and
be sure that you hit the "check" button after the "run" button to submit it. The "check" button runs your code against additional hidden test cases which you must pass in order to receive credit. It's your responsibility to properly submit and be aware of whether you have received green-checkmark credit for your work! (It is also your responsibility to make sure you have properly submitted the final creative task outside of CS Academy.) There is generally no partial credit for autograded problems.