Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This question concerns devising a set of tests for a Python function that cumulatively achieve path coverage. A python module called numberutil.py was provided for

This question concerns devising a set of tests for a Python function that cumulatively achieve path coverage.

A python module called numberutil.py was provided for reference. I do not if I should have attached the program or not.

But the module should contain a function called aswords. The function should accept an integer (0- 999) as a parameter and should return the English language equivalent.

For example, aswords(905) returns the string'Nine hundred and five'.

Your task:

4. Develop a set of 8 test cases that achieve path coverage.

5. Code your tests as a doctest script suitable for execution within Wing IDE.

6. Save your doctest script as testnumberutil.py.

NOTE: make sure the docstring in your script contains a blank line before the closing . (The automarker requires it.)

NOTE: the aswords() function is believed to be error free.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Below is the program that was provided for reference:

word={0:'zero', 1:'one', 2:'two', 3:'three', 4:'four', 5:'five', 6:'six', 7:'seven', 8:'eight', 9:'nine', 10:'ten', 11:'eleven', 12:'twelve', 13:'thirteen', 14:'fourteen', 15:'fifteen', 16:'sixteen', 17:'seventeen', 18:'eighteen', 19:'nineteen', 20:'twenty', 30:'thirty', 40:'forty', 50:'fifty', 60:'sixty', 70:'seventy', 80:'eighty', 90:'ninety', 100:'hundred'}

hundred=100 ten=10

def aswords(n): # Returns a textual description of a number in the range 0..999. words = '' hundreds = n//hundred remainder = n%100 if hundreds>0: words=word[hundreds]+' '+word[hundred] if remainder>0: words=words+' and ' if remainder>0: if remainder<21: words=words+word[n%hundred] else: tens = remainder//ten units words+word[tens*ten] if>0: words = words+' '+word[units] if hundreds==0 and remainder==0: words=word[n] return words

# 1. hundreds=0 and remainder=0 # 2. hundreds=0 and remainder>0 and remainder<21 # 3. hundreds=0 and remainder>0 and remainder>=21 and units=0 # 4. hundreds=0 and remainder>0 and remainder>=21 and units>0 # 5. hundreds>0 and remainder=0 # 6. hundreds>0 and remainder>0 and remainder<21 # 7. hundreds>0 and remainder>0 and remainder>=21 and units=0 # 8. hundreds>0 and remainder>0 and remainder>=21 and units>0

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

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

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago