Question: With this code to start, These objects should initially have a fill of white ( color _ rgb ( 2 5 5 , 2 5

With this code to start, These objects should initially have a fill of white (color_rgb(255,255,255)), and then when the
user clicks the mouse anywhere in the graphics window, should display a visualization of the
aggregate (sum total) number of burials that occurred in each section of the cemetery during the
7-year period. One click should show all of the burials in the data file, with color shades that
make sense in representing the given data.
In other words, your program should initially show the "map" of the cemetery with all areas
having a default or "white" fill. When the user clicks the mouse, it should then show the
cumulative burials after all seven years, so an accumulation of all of the burials that occurred
over the seven years up to and including the year 1878. Note, in this basic assignment, the user
only clicks once, and ALL of the data for ALL of the burials over ALL seven years shows as
color fills in the map ONCE.
The image above shows an example of how your final visualization might look (but with
different data, so as to not give the solution away).
Intuitively, with most colors, the darker areas indicate sections that have more burials than the
lighter areas. Red is, perhaps, an exception to that rule, as a redder red may be intuitively read
as having more burials than a darker red. The choice of color and implementation of the various
shades of the color are critical to the successful completion of this assignment. It is up to you to
choose the color and the shades that you think best represent the total number of burials in a
giveimport turtle
# Set up the turtle environment
screen = turtle.Screen()
screen.setup(width=800, height=600)
t = turtle.Turtle()
t.speed(0)
# Function to draw a rectangle
def draw_rectangle(x, y, width, height, fill_color):
t.penup()
t.goto(x, y)
t.pendown()
t.fillcolor(fill_color)
t.begin_fill()
for _ in range(2):
t.forward(width)
t.right(90)
t.forward(height)
t.right(90)
t.end_fill()
# Function to get burial counts from user
def get_burial_counts():
sections =['Section A', 'Section B', 'Section C', 'Section D']
burial_counts ={}
for section in sections:
count = int(input(f"Enter the number of burials for {section}: "))
burial_counts[section]= count
return burial_counts
# Function to color sections based on burial count
def color_sections(burial_counts):
max_burials = max(burial_counts.values())
# Example section positions and sizes
section_data =[
(-300,200,200,150, 'Section A'),
(-300,50,200,150, 'Section B'),
(100,200,200,150, 'Section C'),
(100,50,200,150, 'Section D'),
]
for x,
y, width, height, section in section_data:
burial_count = burial_counts[section]
# Normalize burial count to color (0-1)
shade = burial_count / max_burials if max_burials >0 else 0
fill_color =(shade,0,0) # Shades of red
draw_rectangle(x, y, width, height, fill_color)
# Draw the initial map with white rectangles
def draw_initial_map():
section_data =[
(-300,200,200,150),
(-300,50,200,150),
(100,200,200,150),
(100,50,200,150),
]
for x, y, width, height in section_data:
draw_rectangle(x, y, width, height, (1,1,1)) # White fill for initial state
# Get burial counts from user
burial_counts = get_burial_counts()
# Draw the initial map
draw_initial_map()
# On click, color sections based on burial data
screen.onclick(lambda x, y: (color_sections(burial_counts), t.hideturtle()))
# Keep the window open until clicked
screen.exitonclick()
With this code to start, These objects should

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!