Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a program in Python 3. Please Below is a code skeleton of a CLI program to test the functions in HW3.py In it,

Please write a program in Python 3. Please

 Below is a code skeleton of a CLI program to test the functions in HW3.py In it, you will write test functions for each of the functions from the module HW3.py . Each test should verify that the function it is testing works correctly. If it does, then the test function should return True , else it should return False . Don't just use the tests from the interactive examples. Think about what the function is supposed to do, and make sure to test not only that, but what it might do in unusual circumstances. (*See note below) Use argparse to implement the CLI portion of the program so it works as shown below. Output from the program should look like this when you use the -h help flag: $ python HW3_test.py -h usage: HW3_test.py [-h] [-u] [-w] [-l] optional arguments: -h, --help show this help message and exit -u, --unique Flag to test the unique function from HW3 -w, --words Flag to test the words_containing function from HW3 -l, --len Flag to test the len_test function from HW3 If no arguments are given, the program should do nothing. Since there are only flags (ie, no string arguments as in the lecture examples), you will need to check the argparse documentation to see how to implement flag arguments. ######################################################## ###Program Example: import argparse from HW3 import words_containing, len_test, unique def test_unique(): """Return True/False if the test of unique passes/fails"""  def test_words_containing(): """Return True/False if the test of words_containing passes/fails"""  def test_len_test(): """Return True/False if the test of len_test passes/fails"""  if __name__ == "__main__": parser = argparse.ArgumentParser() # Set up argparse information here # Based on user input, run test(s) requested and report outcome 

show output.

##################################################################################

##################################################################################

##HW3.py:

def unique(iterable): """Yield iterable elements in order, skipping duplicate values.""" def words_containing(sentence, letter): """ Given a sentence, returns list of words that contain the letter.  Letter given is lowercase. Sentence can be mixed case, and the  case should be ignored for searching.  """  # Splitting the word words = sentence.split() # Declaring the list to store words that contains the letter contains = [] # Iterating through all the words for i in words: # Checking whether the letter is present in the lowercased word if letter in i.lower(): # Added word to list contains.append(i) print(contains) sentence = input("Enter the sentence: ") char = 'a' words_containing(sentence, char) 

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

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

ISBN: 0201844524, 978-0201844528

More Books

Students also viewed these Databases questions