Question: PYHTON CODING FUNCTIONS HELP Part 2. Also need help with these last functions. Requirements/restraints and the map referred to is pictured in the screenshot. Need

PYHTON CODING FUNCTIONS HELP Part 2. Also need help with these last functions. Requirements/restraints and the map referred to is pictured in the screenshot. Need help with these 4 tasks:
Function 4:
def is_map(map) : given a map (see screenshot), does it meet the following criteria? 1) it is a list of lists of values of type int; 2) it has at least one row and one column; 3) its rectangular (all sub-lists are same length); 4) only non-negative ints are present (zero and up is accepted)
Assume: map is a list.
is_map([[1,2,3],[0,1,5]) True
is_map([[[1,2,3,4],[5],[6,7]]) False # not rectangular
is_map([[-2,False, [1,2,3]], [4,5,6]]) False #can't contain negatives or non-ints
Function 5:
def neighbors(map, r, c): Given a map and a location, there are up to eight possible locations immediately around it that might also exist on the map (unless along an edge or corner position). Build up a list of tuples, each tuple storing the (row, column) of the neighbors. They must be in order from lowest-row to later, lowest-column to later. This happens to mean the same ordering as they appear when the map is printed out. If the point isn't on the map, return an empty list!!
Assume: map is a map as defined above, and r and c are int values.
neighbors(map1,1,1) [(0, 0), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1), (2, 2)]
neighbors(map2,0,3) [(0, 2), (0, 4), (1, 2), (1, 3), (1, 4)]
neighbors(map2,2,0) [(1, 0), (1, 1), (2, 1)]
Function 6:
def water_adjacent(map, r, c): Given a map and a location, are any of that spot's neighbors water? Water spots do not count themselves, only their neighbors. If (r,c) isn't on the map, the answer is False.
Assume: map is a map as defined above, and r and c are int values.
water_adjacent(map1,1,1) True
water_adjacent(map1,2,2) False
water_adjacent([[1,1,1],[1,0,1],[1,1,1]],1,1) False
Function 7:
def count_coastline(map): Given a map, how many spots are adjacent to water
Assume: map is a map as defined above, and r and c are int values.
count_coastline(map1) 9
count_coastline(map2) 11
count_coastline([[1,1,1],[1,0,1],[1,1,1]]) 8
 PYHTON CODING FUNCTIONS HELP Part 2. Also need help with these
last functions. Requirements/restraints and the map referred to is pictured in the

Background The purpose of this assignment is to practice building, inspecting, and modifying 2D lists effectively. This often requires nested for-loops, but not always. It involves thinking of the structure like an N x M matrix of labeled spots, each with a row-and column-index. As before, we are restricting ourselves to the most basic functionalities, and any others that you want, you should implement yourself. Two-dimensional lists aren't conceptually more difficult than single-dimension lists, but in practice the nested loops, aliasing, and more complex traversals and interactions merit some extra practice and thought Project Basics document (part of assignment): http://cs.gmu.edu/-marks/112/projects/project basics,pdf Project Four tester file: http://cs.gmu.edu marks/112/projects/tester4p.py Grading Code passes shared tests: We11-commented/submitted: 1 TOTAL: 90 100 +5 extra credit What can I use? You may only use the following things. You may ask about adding things to a list, but we are unlikely to add anything. If you use something disallowed, it's not an honor code violation, you just won't get points for any tests that use them. Restrictions no modules may be imported. you may only use built-in functions and methods explicitly listed below in the allowed section. list comprehensions and lambdas may not be used on this project Allowed basic statements, variables, operators, del, indexing, slicing, in, are all allowed any form of control flow we've covered is allowed (if else, loops, etc) only these built-in functions: range), len(), int), str, type(), list) only these built-in methods: s.split), s.join(), s.pop), xs.append(), xs.extend() xs.insert(), s.format() on extra credit: xs.sort() method (only when indicated!) calling other functions of the project (and your own defined helper functions). Please do this! e Hint In our solution, we only used range, len, type, pop(), and .append(). (And.sort() just on the extra credit as directed by the instructions). Remember: your grade is significantly based on passing test cases-try to completely finish individual functions before moving on. The easiest way to implement many functions is to call the earlierleasier functions, so it'll pay off to complete functions before trying others. Don't let yourself be "kind of done" with a function, but miss all the tests

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 Databases Questions!