Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The keys in this dictionary are the predatores and the values in the dictionary

ID: 3706873 • Letter: T

Question

The keys in this dictionary are the predatores and the values in the dictionary are the prey.

(2) make a function to determine the apex predator in the list.Apex predators are those animals that are keys in the dictionary that do not appear in any of the lists of animals eaten.

(3)make a function to determine the producers in the list for food web. A producer will occur in the list of prey of a predator, but not occur as a predator itself. There should be no duplicates in this list.

(4)make a function for neither the apex predators and producers. These are the items in the dictionary of food web that is not listed in part 2 and part 3

(6)make a function for tastiest organism. Find the organism that appeared the most in the list as prey in the dictionary.

Predators and Prey: Grasshopper eats Terrestrial plants Harvest mouse eats Grasshopper and Terrestrial plants Hawk eats Harvest mouse, Rat, Shrew and Vole Heron eats shrimp and Smelt Mallard eats Grasshopper, shrimp and Terrestrial plants Owl eats Mallard, Rat, Sandpiper and Sparrow Rat eats Grasshopper, Sparrow and Terrestrial plants Sandpiper eats Shrimp Shrew eats Grasshopper Shrimp eats Aquatic plants Sparrow eats Grasshopper and Terrestrial plants Vole eats Grasshopper and Terrestrial plants

Explanation / Answer

# Hello World program in Python

  

print "Hello World! "

check={

"gh":"Grasshopper",

"tp":"Terrestrial Plants",

"hm":"Harvest Mouse",

"hw":"Hawk",

"rt":"Rat",

"sh":"Shrew",

"vo":"Vole",

"he":"Heron",

"sm":"Shrimp",

"ow":"Owl",

"sl":"Smelt",

"ml":"Mallard",

"sp":"Sandpiper",

"sw":"Sparrow",

"ap":"Aquatic Plants"

  

}

predators = {"gh":["tp"],

"hm":["gh","tp"],

"hw":["hm","rt","sh","vo"],

"he":["sm","sl"],

"ml":["gh","sm","tp"],

"ow":["ml","rt","sp","sw"],

"rt":["gh","sw","tp"],

"sp":["sm"],

"sh":["gh"],

"sm":["ap"],

"sl":["ap","sm"],

"sw":["gh","tp"],

"vo":["gh","tp"]

  

  

}

def apexPredator():

preys=set([])

for val in predators.itervalues():

for pr in val:

preys.add(pr)

result=[]

for keys in predators.iterkeys():

if not keys in preys:

result.append(check[keys])

return result

def producers():

eaters=set([])

for keys in predators.iterkeys():

eaters.add(keys)

result=set([])

for val in predators.itervalues():

for pr in val:

if not pr in eaters:

result.add(check[pr])

return list(result)

def part4():

part2=apexPredator()

part3=producers()

result=set([])

tempSet=set([])

for val in part2:

tempSet.add(val)

for val in part3:

tempSet.add(val)

for keys in check.iterkeys():

if not keys in tempSet:

result.add(check[keys])

return list(result)

def tastiest():

tempDict={}

for val in predators.itervalues():

for pr in val:

if pr in tempDict:

tempDict[pr]+=1;

else:

tempDict[pr]=1;

#print "sh"

#print tempDict

maxVal=0;

maxKey="";

for keys in tempDict.iterkeys():

if tempDict[keys]>maxVal:

maxVal=tempDict[keys]

maxKey=keys

return check[maxKey]

You can also use the code from here : https://codeshare.io/albXn8

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote