Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For each function listed below ( invert , favorite _ color, count, alphabetize, update _ attendance ) , you are to define at least 3
For each function listed below invert favoritecolor, count, alphabetize, updateattendance you are to define at least x unit test functions. Remember that a unit test function starts with test
The unit tests should consist of:
Two use cases: expected use cases of a function
One edge case: unexpected use cases of a function
Include descriptive function names and docstrings, so that it captures what is being tested.
def invertdictionary:
Invert Function."""
inverteddict
for key, value in dictionary.items:
if value in inverteddict:
raise KeyErrorDuplicate value encountered while inverting dictionary"
inverteddictvalue key
return inverteddict
def favoritecolorcolors:
Favorite Color Function."""
colorcount
for color in colors.values:
colorcountcolor colorcount.getcolor
maxcount maxcolorcount.values
for name, color in colors.items:
if colorcountcolor maxcount:
return color
def countlst:
Count Function."""
countdict
for item in lst:
if item in countdict:
countdictitem
else:
countdictitem
return countdict
def alphabetizerwords:
Alphabetizer Function."""
alphabetdict
for word in words:
firstletter wordlower
if firstletter in alphabetdict:
alphabetdictfirstletterappendword
else:
alphabetdictfirstletterword
return alphabetdict
def updateattendanceattendancelog day, student:
Update Attendance Function."""
if day in attendancelog:
attendancelogdayappendstudent
else:
attendancelogdaystudent
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started