param: start_idx (int) - an expected starting             value for idx (default is 0); gets             subtracted from idx for 0-based indexing     The function first checks if i

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 28SA
icon
Related questions
Question

def delete_item(...):
    """
    param: info_list - a list from which to remove
            an item
    param: idx (str) - a string that is expected to
            contain an integer index of an item in
            the in_list
    param: start_idx (int) - an expected starting
            value for idx (default is 0); gets
            subtracted from idx for 0-based indexing

    The function first checks if info_list is empty.
    The function then calls is_valid_index() to verify
    that the provided index idx is a valid positive
    index that can access an element from info_list.
    On success, the function saves the item from info_list
    and returns it after it is deleted from info_list.

    returns:
    If info_list is empty, return 0.
    If is_valid_index() returns False, return -1.
    Otherwise, on success, the function returns the element
    that was just removed from info_list.

    Helper functions:
    - is_valid_index()
    """

Deleting a category
• Define delete_item() in the functions.py (see the function stub below).
o A Implement this function according to the function documentation. Read the documentation carefully first, before
implementing anything.
Good news - you should have already implemented most of this functionality in the previous labs! :-)
Add the tests from the Test Your Code section to your tests.py
• Add (and run!) your own new assert statements - pay close attention to the cases described in the function documentation
that should cause errors.
• Test each case by writing separate assertions.
Transcribed Image Text:Deleting a category • Define delete_item() in the functions.py (see the function stub below). o A Implement this function according to the function documentation. Read the documentation carefully first, before implementing anything. Good news - you should have already implemented most of this functionality in the previous labs! :-) Add the tests from the Test Your Code section to your tests.py • Add (and run!) your own new assert statements - pay close attention to the cases described in the function documentation that should cause errors. • Test each case by writing separate assertions.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Types of trees
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning