Python Homework Help
Using the facilities provided by the acctmis module, write python functions to answer all of the following three questions, and store your code in a file called "area_codes.py":
Q1. get_area_codes() - this should read the web_page at https://www.bennetyee.org/ucsd-pages/area.html (Links to an external site.)
scrape the codes from that page, and produce a dictionary (which should be stored in a global variable CODES). If the function completes successfully, then it should return the value True, if it doesn't complete, then print an error message, and return the value False. The dictionary in CODES should have as the key the area_code, and as the data a list containing the following:
- state code (e.g. 'NJ')
- time-zone (e.g. '-5')
- description (e.g. "N New Jersey: Jersey City, Hackensack...")
Q2, get_state_for_code(area_code) - this should take an area code as a string (e.g. "201"), look up the entry in the CODES global variable produced by the answer to Q1, and return just the state code as a string. Eg. get_state_for_code("201') --> "NJ". If no value is found for the area code, or if the area_code is not in the right format (a string of length 3 with just numbers in it), then print an error message to the screen, and return the value None.
Q3. get_data_for_number(phone_number) - this should take a US 10-digit phone number which could be in any of the below formats, extract the area code from the number, and return all the data about that area_code as a list (i.e. the entry in the CODES variable, produced by the answer to Q1). If the phone number is not in the right format, then an error message should be printed and the result None should be returned from the function. If no entry is found for the area code, then a message should be printed, and None returned from the function. Valid formats for the number are:
- Any integer number containing exactly 10 digits - e.g. 2014553810
- '(XXX) XXX XXXX' - a string in this format, where X is one of the digits 0-9
- 'XXX-XXX-XXXX' - a string in this format, where X is one of the digits 0-9
- 'XXXXXXXXXX' - a string in this format, where X is one of the digits 0-9
Notes: You should handle reasonably expected data "errors" in your code throughout. You should use the functions provided by acctmis to do the web-page reading (and other things) by importing that module (import acctmis) at the top of your "area_codes.py" file, rather than by copying and pasting the functions into your code.
Hint: the data for the area codes on the given web page is in a table.
Get Help With a similar task to - Python Homework Help
Related Questions
Tutlance Experts offer help in a wide range of topics. Here are some of our top services:
- Math homework help
- Nursing homework help
- Statistics homework help
- Nursing coursework help
- Capstone project writing services
- Essay writers for hire
- Case study writing help
- Buy college papers online
- Buy college research papers
- College homework help
- Professional resume writing services
- Programming homework help
- Coursework writing help
- Term paper writing help
- Biology homework help
- Do my physics homework
- Dissertation data analysis help
- PhD Dissertation writing services
- Chemistry homework help
Post your project now for free and watch professional experts outbid each other in just a few minutes.