Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You must write this assignment starting with Template for Functions {chapter 51-}.py. Refer to the Style Requirementsprlf document posted in Blackboard for more requirements. Data

image text in transcribedimage text in transcribedimage text in transcribed
You must write this assignment starting with Template for Functions {chapter 51-}.py. Refer to the Style Requirementsprlf document posted in Blackboard for more requirements. Data les will be supplied with these instructions. Use Template for Libraries {chapter 5+).py for writing modules that will be imported. The Problem Write a file named FinalExam.py with a main program that imports the library module FinalExamFunctions.py and calls the sentence prooessing function [described below] as long as the user says they want to oontinue. Build a library module named FinalExamFunctions.py with the 3 functions described below. Global constants: build a tuple named ALP HABEr, including both lowercase and uppercase letters, i.e., ALPHABET = tuplel: ['a', 'b', ...,'2, 'A', '3', 'z'] :I. Make sure the lowercase letter are first in the list. Also use a global constant for the default data file name, which is "characters.txt". Write a sentence prooessingfunction that passes the default file name to a le reading function and receives a buffer list in return. It then passes that list to the list processing function and reoeives a sentenoe list in return. Finally, the sentence processing function prints the sentence list one item at time with a space between the list items. Write a le reading function that tries to open the le named in the parameter and read le of numbers into a list named buffer. Use a general purpose exception to handle any error: if there is ANY error, simply leave the buffer list empty. Finally, return the list. Write a list processing function which receives a list as a parameter and loops through the list doing the following: convert each list element to integer and use the value as an index ofALP HABEf to get a character, which it ooncatenates to a string named thisWo rd. If the oonversion or index step generates ANY error, append the thisWord to a list named sentence [but only if thisWord is not an empty string at that point] and then empty thisWord before continuing to loop through the buffer list. When the loop reaches the end of the list, he sure the last word is also concatenated to the sentence list. After the sentence list is built, return the sentence list to the sentence processing function. Extra credit (10 points) Build another global oonstant tuple of punctuation symbols that you will accept ['.', ',', ';', '?', and so on -- you decide]. If a list item causes an error in the list processing function, catch it with the exception as described above, but test to see if it is in the punctuation list. If it is, append the punctuation to the word before proceeding to append the word to the sentence list. Extra credit ('70 points] Add a function to the library that allows you to type a string which will use the alphabet tuple to write the index of your typed characters, one at a time, to build a data file named "characters.txt" that can be read by the sentence processing function. The input is typed as a sentence, not as single words, or characters, at a time. Modify the main program to offer a menu choice: call the typing function, call the sentence processing function, or quit. Continue offering this choioe until the user chooses to quit. ~ Template for Functions (chapter 5+).py - C:\\Users\\priya\\Downloads\\Template for Functions (chapter 5+).py (3.10.0) File Edit Format Run Options Window Help Program Description : template with a stub function Author: Date: Revised # import library modules here # Define global constants (name in ALL_CAPS) def main () : # Declare Variable types (EVERY variable used in this main program) stub ( ) # End Program Function stub () # Description: just here as a stub: rename and rewrite for real programs Calls : none Parameters : none Returns : none def stub ( ) : # Declare Local Variable types (NOT parameters) print ( "stub" ) # so I can test-run the template and not get an error # Return the return variable, if any #} Function stub () main ()*Template for Libraries (chapter 5+) (1).py - C:\\Users\\priya\\Downloads\\Template for Libraries (chapter 5+) (1).py (3.10.0)* File Edit Format Run Options Window Help # Library Functions Included in Library: stub ( ) () () Author: Date: # Revised: # # import library modules here # Define global constants (name in ALL_CAPS) # Function stub () Description : just here as a stub: rename and rewrite for real programs Calls : none Parameters : none Returns : none def stub ( ) : # Declare Local Variable types (NOT parameters) print ( "stub" ) # so I can test-run the template and not get an error # Return the return variable, if any #} Function stub ( ) # Other function definitions, if any # End Module

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

What primary role do trade unions fill in China?

Answered: 1 week ago

Question

10 Contrast the three main types of learning.

Answered: 1 week ago