logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

ou must write this assignment starting with Template for Functions (chapter 5+).py. Refer to the Style Requirements.pdf document posted in Blackboard for more requirements.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Write a file named FinalExam.py with a main program that imports the library module FinalExamFunctions.py and calls the sentence processing function (described below) as long as the user says they want to continue. Build a library module named FinalExamFunctions.py with the 3 functions described below. Global constants: build a tuple named ALPHABET, including both lowercase and uppercase letters, i.e., ALPHABET = tuple( [ 'a', 'b', ...,'z', 'A', 'B', ... 'Z' ] ). 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 processing function that passes the default file name to a file reading function and receives a buffer list in return. It then passes that list to the list processing function and receives a sentence 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 file reading function that tries to open the file named in the parameter and read file 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 of ALPHABET to get a character, which it concatenates to a string named thisWord. If the conversion 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, be 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.

 

1336 Comprehensive Final Examination

Page 1 of 2

General Statement

You must write this assignment starting with Template for Functions (chapter 5+).py. Refer to the Style

Requirements.pdf document posted in Blackboard for more requirements. Data files 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 processing function (described below) as long as the user says they want to continue.

Build a library module named FinalExamFunctions.py with the 3 functions described below.

Global constants: build a tuple named ALPHABET, including both lowercase and uppercase letters, i.e.,

ALPHABET = tuple( [ 'a', 'b', ...,'z', 'A', 'B', ... 'Z' ] ).

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 processing function that passes the default file name to a file reading function and receives

a buffer list in return. It then passes that list to the list processing function and receives a sentence 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 file reading function that tries to open the file named in the parameter and read file 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 of ALPHABET to get a character,

which it concatenates to a string named thisWord.

If the conversion 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, be 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 constant 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 choice until the user chooses to quit.

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

562 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

734 Answers

Hire Me
expert
Husnain SaeedComputer science

590 Answers

Hire Me
expert
Atharva PatilComputer science

819 Answers

Hire Me