Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

Explain a corporate university and its benefits.

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago