Question: Problem 2 . Consider the following functions: def f ( x ) : st = dict ( ) for v in x: if v in

Problem 2. Consider the following functions:
def f(x):
st = dict ()
for v in x:
if v in st:
st[v]+=1 else:
st[v]=1 return st
def g(x):
return max(f(x).values())
def h(x):
y = f(x)
z = g(x)
for v in y.keys():
if y[v]== z: return v
return -1
a. What does f("amanaplanacanalpanama")["p"] return?
b. Whatisthevalueoftheexpressionf("amanaplanacanalpanama")["c"]+ f("amanaplanacanalpanama")["n"]?
c. What does g("amanaplanacanalpanama") return?
d. What does h("amanaplanacanalpanama") return?
e. What is the value of the expression h("amanaplanacanalpanama")* g("abracadabra")?

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!