Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Before doing the exercise, make sure you have installed introcs package and imported it already. Here is a function that is not working properly due

Before doing the exercise, make sure you have installed introcs package and imported it already.

Here is a function that is not working properly due to the special precondition. Please use introcs.assert_equals() to test the result and indicate what is the problem of this function.

Use introcs.assert_equals() again to make sure the input qualifies the precondition and test your result again. (consider what n.find(' ') will return if the input is invalid)

"""

A module with a single, non-working function. The function in this module has a bug (in the sense that it does not satisfy its specification). This allows us to show off debugging. 

""" def last_name_first(n):

"""

Returns: copy of n but in the form 'last-name, first-name'

Parameter n: the person's name

Precondition: n is in the form 'first-name last-name' with one or more blanks between the two names no spaces in or

"""

 end_first = n.find(' ') 
 first = n[:end_first] 
 last = n[end_first+1:] 
 return last+', '+first 

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

Who establishes engineering standards?

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago