Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
