Question: def incrementKeyCount ( D , key ) : ' ' Function that takes in a Dictionary object ( D ) containing KEY:VALUE pairs where the

def incrementKeyCount(D, key):
'' Function that takes in a Dictionary object (D) containing KEY:VALUE
pairs where the VALUE is a count representing the number of times the KEY
is incremented.
If the parameter key does not exist in D, then a new KEY: VALUE
pair is created in D with key:1(the first time the key is incremented).
If the parameter key does exist in D, then the key's VALUE is
incremented by 1.
Note that since dictionaries are mutable, this function does
not return a value.
Consider using the in operator to check if a key exists in a Dictionary
Assert examples below illustrate correct behavior for this function
''
# COMPLETE YOUR FUNCTION DEFINITION HERE
dict1={}
assert len(dict1)=0
assert incrementKeyCount(dict1,"CS8")== None
assert len(dict1)=1
assert ("CS8" in dict1)== True
assert dict1["CS8"]==1
assert incrementKeyCount(dict1,"CS8")== None
assert len(dict1)=1
assert dict1["CS8"]==2
assert incrementKeyCount(dict1, "MATH3A")== None
assert len(dict1)=2
assert ("MATH3A" in dict1)== True
assert dict1["MATH3A"]=1
 def incrementKeyCount(D, key): '' Function that takes in a Dictionary object

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!