Computer Science AP/X CSCI-140/242 Mondrian Recursion Lab 2: 1 Implementation (75%)
Computer Science AP/X CSCI-140/242 Mondrian Recursion Lab 2: 1 Implementation (75%)
1 Implementation (75%)
You will individually develop a program called mondrian.py that implements the Mon-
drian recursion problem from problem solving and the in-lab activity.
1
Enter depth? 6
Random subdivisions? n
Rectangle Surface Areas:
blue: 158750
red: 166250
white: 162500
yellow: 152500
Total Surface Area: 640000
1.3.2 Randomization
To select a random element from a list use:
c o l o r = random . c h o i c e (COLORS) # COLORS i s a l i s t o f s t r i n g s
2
v a l = random . r a n d i n t ( 1 0 , 20 ) # random number between 10−20 i n c l u s i v e
If you want to debug your program and get random values that are the same, you can
seed it with a fixed number so that calls to randint() will always generate with the same
values and order:
v a l = random . s e e d ( 1 0 )
In addition, you should add a call to the end of your main function, just before calling
turtle.mainloop():
t u r t l e . update ( )
2 Grading
The assignment grade is based on these factors:
• Problem Solving: 15%
• In-Lab Activity: 10%
• Functionality: 55%
– Uniform rectangles: 20%
– Random rectangles: 20%
– Surface area computation: 15%
• Design: 10% - Your implementation uses recursions and functions to promote code
reuse.
• Code Style and Documentation: 10%
3 Submission
Go to your project’s src folder and zip it up. Rename the zip file to lab2.zip. Upload
this zip to the MyCourses Assignment dropbox by the due date.
• To zip on Windows, right click on the src folder and select Send to -> Compressed
(zipped) folder.
• To zip on MacOS, right click on the src folder and select Compress "src".