Answered step by step
Verified Expert Solution
Question
1 Approved Answer
test plan for :# Write your count _ type function below: ( 2 marks ) # * * * * * * * * *
test plan for :# Write your counttype function below: marks
#
def counttypemapdata, maptype:
return sumrowcountmaptype for row in mapdata
# Count the number of times maptype occurs in mapdata
#
# Write your classifymap function below: marks
#
def classifymapmapdata:
totalcells sumlenrow for row in mapdata
if counttypemapdata, R totalcells:
return 'Suburban'
elif counttypemapdata, A totalcells:
return 'Farmland'
elif counttypemapdata, U counttypemapdata, W totalcells:
return 'Conservation'
elif counttypemapdata, C totalcells and counttypemapdata, U counttypemapdata, A totalcells :
return 'City'
else:
return 'Mixed'
#
# Write your isolatetype function below: marks
#
def isolatetypemapdata, maptype:
return cell if cell maptype else for cell in row for row in mapdata
# Create a new list of lists where non maptype entries are replaced with
#
# Write your commerciallybuildable function below: marks
#
def commerciallybuildablemapdata, i j:
if i or j or i lenmapdata or j lenmapdata: # Check if the cell is not on the edge
return False
if mapdataijU: # Check if the cell has map type U
return False
# Check adjacent cells for map types R and A
for di dj in :
if mapdatai dij dj in RA:
return False
return True
# If all checks pass, the cell is commercially buildable return true
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started