def update_task(task_list, task_id, task_field, task_update):     """ Given     * the task list (`task_list`)     * the task index that has been selected (`task_id`)     * the field of the selected task (`task_field`)     * the updated information (`task_update`)     Validate the parameters to check for syntax and structure.      If all validations passed, return a tuple with a boolean True and      the updated task (a dictionary from the `task_list` at the provided `task_id`).     Ff validations fail, return a tuple with a boolean False and      a string with the task_field that caused the error during validation.     """     task_list = input()     task_id = input()     task_field = input()     task_update = input()     if task_id is is_valid_index():         if (task_field is in task_list.item()):             return True , task_list(task_id)         else:             return (False , "field")                       else:         return (False, "idx")   fields = [     'name',     'description',     'deadline',     'priority',     'completed'     ] #you may use this to validate field_name

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

def update_task(task_list, task_id, task_field, task_update):
    """ Given
    * the task list (`task_list`)
    * the task index that has been selected (`task_id`)
    * the field of the selected task (`task_field`)
    * the updated information (`task_update`)
    Validate the parameters to check for syntax and structure. 
    If all validations passed, return a tuple with a boolean True and 
    the updated task (a dictionary from the `task_list` at the provided `task_id`).
    Ff validations fail, return a tuple with a boolean False and 
    a string with the task_field that caused the error during validation.
    """
    task_list = input()
    task_id = input()
    task_field = input()
    task_update = input()
    if task_id is is_valid_index():
        if (task_field is in task_list.item()):
            return True , task_list(task_id)
        else:
            return (False , "field")
        
        
    else:
        return (False, "idx")

  fields = [
    'name',
    'description',
    'deadline',
    'priority',
    'completed'
    ] #you may use this to validate field_name


    if task_field == 'name': # use the correct function call(s)
        if ...:#validate update using the correct function call(s)
            return #TODO: return the necessary tuple
        else:
            return #TODO: update the task list accordingly
    elif... #TODO: continue checking the next field
    
    return True #TODO: return the proper value if all validations passed
        

if __name__ == "__main__":

    # for testing purposes, so you can observe the output
    my_list = [{
        'name': 'get groceries',
        'description': 'buy some jam and peanut butter',
        'deadline': '02/23/2022',
        'priority': 2,
        'completed': False
        },
        {
        'name': 'get some sleep',
        'description': '8 hours of sleep is necessary',
        'deadline': '02/03/2022',
        'priority': 3,
        'completed': True
        },
        {
        'name': 'compar. lit essay',
        'description': "finish comparative lit essay that's overdue",
        'deadline': '02/15/2022',
        'priority': 4,
        'completed': True
        }]

    result = update_task(my_list, '5', 'name', 'go clubbing')
    assert result[1] == "idx"
    assert result[0] == False
    print(f"--> update_task(my_list, '5', 'name', 'go clubbing') "+
          f"successfully returned error with `{result[1]}`\n")
    
    
    result = update_task(my_list, '1', 'Get Gift', 'I\'m quite hungry though')
    assert result[1] == "field"
    assert result[0] == False
    print(f"--> update_task(my_list, '1', 'Get Gift', 'I\'m quite hungry though') "+
          f"successfully returned error with `{result[1]}`\n")
    

    result = update_task(my_list, '1', 'deadline', 'never')
    assert result[1] == "deadline"
    assert result[0] == False
    print(f"--> update_task(my_list, '1', 'deadline', 'never') "+
          f"successfully returned error with `{result[1]}`\n")
    

    result = update_task(my_list, '1', 'priority', 'pants on FIRE!!!!')
    assert result[1] == "priority"
    assert result[0] == False
    print(f"--> update_task(my_list, '1', 'priority', 'pants on FIRE!!!!') "+
          f"successfully returned error with `{result[1]}`\n")
    

    result = update_task(my_list, '1', 'completed', 'technically, yes')
    assert result[1] == "completed"
    assert result[0] == False
    print(f"--> update_task(my_list, '1', 'completed', 'technically, yes') "+
          f"successfully returned error with `{result[1]}`\n")
    

     result = update_task(my_list, '1', 'deadline', '01/22/19')

    assert result[0] == True

    assert result[1]['deadline'] == '01/22/19'

    print(f"--> update_task(my_list, '1', 'Deadline', '01/22/19' "+

          f"successfully returned updated task: n{result[1]}n")

    
    result = update_task(my_list, '1', 'completed', 'no')
    assert result[0] == True
    assert result[1]['completed'] == False
    print(f"--> update_task(my_list, '1', 'completed', 'no') "+
          f"successfully returned updated task: \n{result[1]}\n")
    
    print(">>All assertions successfully run...\n")
    

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Introduction to Template
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education