Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with Parts 1 and 2 of this problem! I am very lost Instructions - Please follow all instructions closely. There is no

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

I need help with Parts 1 and 2 of this problem! I am very lost

Instructions - Please follow all instructions closely. There is no penalty for going "above and beyond" the assignment requirements. However, failure to meet all required parts can affect your grade. Please consult the rubric for each section. - Because of the nature of this lab, most of your files must be of the "raw" Python type (*.py). The driver, however, can be a Jupyter Notebook file. Part I Create a Python module to determine if strings are in a format acceptable for parsing into other data types. - Create a parent folder called Lab2. This is where you will create a "test driver" program to exercise the modules and package you are about to create. - Create the test driver file in the Lab2 folder, call it HelpersDriver.py OR HelpersDriver.ipynb (depending on whether or not you want to use Jupyter Notebook or raw Python for the tester). - We'll work on this file in another section. - In the Lab2 folder create another folder called Helpers. This will represent the Helpers package. - In the Helpers folder create a new file called init_.py - In the Helpers folder create. two new files called DataTypeHelpers.py and InputHelpers.py We'll look at InputHelpers.py later in another section. Here's the folder/file layout so far... .. Lab2 Helpers init_py DataTypeHelpers.py Inputhelpers.py HelpersDriver.py (or HelpersDriver.ipynb) Intermediate Python Programming LAB 2 Page: 2 In the DataTypeHelpers.py file, you will need to create several functions - here are their signatures and what they are supposed to do: def is Int(value): - This function accepts a string value and returns True if that value can be parsed to an int data type, False otherwise. - Assume any error will simply return False. - Note: See end of assignment for tips on this method (try it for yourself first!). def isfloat(value): - This function accepts a string value and returns True if that value can be parsed to a float data type, False otherwise. - Assume any error will simply return False. Extra Credit def isDate(value): - This function accepts a string value and returns True if that value can be parsed to a datetime data type in ISO serialization format (yyyy-mm-dd), False otherwise. - Assume any error will simply return False. Note: The top of the file should define an all list containing the names of the above functions. Requirements: - Each of the functions should not cause a "crash" no matter the input. Assume if the data is bad that the result from each function should be False. - The all_ list is required. - Don't forget to include any from/import statements that may be required for your code. - Ex: from datetime import datetime S Part II Create a Python module that prompts the user for a value of a specific data type. Ensure you have a Python file called Inputhelpers.py in the same Helpers folder that DataTypeHelpers.py is in. In this file you will need to create several functions - here are their signatures and what they are supposed to do: def inputint(prompt = "Enter an integer: ", min_value =, max_value =100 ): - In a loop, this function will use the input() method to display the "prompt" variable and read in a string. - The function will then call the isInt() function defined in the DataTypeHelpers module to determine if the provided value can be parsed into an int using the int() function. - If isInt() returns False, print a statement to the terminal informing the user that the entered text needs to be in the int format and continue the loop so the user will get prompted for input again. If isInt() returns True, then you need convert the string value into an int and ensure it falls between min_value and max_value, inclusively. - If the value is out of range, then inform the user with a print statement that value is out of range and continue the loop so the user will get prompted for input again. - Otherwise, return the parsed int value. def inputfloat(prompt = "Enter a float: ", min_value =, max_value =100) : - In a loop, this function will use the input() method to display the "prompt" variable and read in a string. - The function will then call the isFloat() function defined in the DataTypeHelpers module to determine if the provided value can be parsed into a float using the float() function. If isFloat() returns False, print a statement to the terminal informing the user that the entered text needs to be in the float format and continue the loop so the user will get prompted for input again. If isFloat() returns True, then you need convert the string value into a float and ensure it falls between min_value and max_value, inclusively. - If the value is out of range, then inform the user with a print statement that value is out of range and continue the loop so the user will get prompted for in put again. - Otherwise, return the parsed float value. def inputstring (prompt = "Enter a string: ", min_length =,max length = 100): - In a loop, this function will use the input() method to display the "prompt" variable and read in a string. - Since this value is already the correct data type, all you need to do is check that the length of the string falls between min_length and max_length. - If the length is out of range, then inform the user with a print statement that length is out of range and continue the loop so the user will get prompted for input again. Otherwise, return the string. Extra Credit def inputDate(prompt = "Enter a date in ISo format (yyyy-mm-dd): "): Intermediate Python Programming LAB 2 Page: 4 - In a loop, this function will use the input() method to display the "prompt" variable and read in a string. - The function will then call the isDate() function defined in the DataTypeHelpers module to determine if the provided value can be parsed into a date using the datetime.fromisoformat() function. - If isDate() retums False, print a statement to the terminal informing the user that the entered text needs to be in the "yyyy-mm-dd" format and continue the loop so the user will get prompted for input again. - If isDate() returns True, then you need convert the string value into a date using datetime.fromisoformat () and return the parsed value. Requirements: - Each method must continue to prompt the user for input until the correct format is entered AND the value is in the correct range. - The all list is required, containing the above-defined method names. - Don't forget to include any from/import statements that may be required for your code (datetime). Part III Finalize the Helpers package and test it all. The init_.py file must have a from/import statement to include all of the functions from InputHelpers. Note: The _all variable is not needed in init .py The HelpersDriver.py/ipynb file must import the Helpers package. In the driver file, test each of the input methods created in part II. Requirements

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions

Question

Classify delivery styles by type.

Answered: 1 week ago