Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab03 - Exercise - Prefix (1 point) Open prefix.py and complete the function prefix_search() according to its documentation. Some tests have been added in prefix_test.py.

image text in transcribed
image text in transcribed
image text in transcribed
Lab03 - Exercise - Prefix (1 point) Open prefix.py and complete the function prefix_search() according to its documentation. Some tests have been added in prefix_test.py. Ensure your solution passes those tests then write some of your own such that you have 100% code coverage of prefix.py. To measure the coverage run coverage run-m pytest from the root of this repo. To view the coverage report use coverage report. You can see your coverage percentage in the indicator at the top of this page. It will update after the pipeline completes. Note that the pipeline will only fail if tests fail, so you need to pay attention to both the pipeline success/failure and also the coverage percentage. Please note: Coverage is not covered until the week 3 lectures, so you may not be able to complete part of this lab until then 2 3 4 5 6 7 8 9 10 11 prefix.py x prefix_test.py 1 def prefix_search(dictionary, key prefix): Given a dictionary (with strings for keys) and a string, returns a new dictionary containing only the keys (and their corresponding values) for which the string is a prefix. If the string is not a prefix for any key, a keyError is raised. You can assume that you will not be given any empty strings in dictionary or as key prefix For example, >>> prefix search({"ac": 1, "ba": 2, "ab": 3). "a") {'ac': 1. 'ab': 3) pass from prefix import prefix_search import pytest def test documentation (): assert prefix_search({"ac": 1, "ba": 2, "ab": 3}, "a") == { "ac": 1, "ab": 3} def test_exact_match(): assert prefix_search({ "category":"math", "cat": "animal"), "cat") == {"category":"math", "cat": "animal"}

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

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago