Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CS 230

Introduction to Programming with Python

Program 3: Grad School Application Cover Letter

The McCallum Graduate School of Business at Bentley offers a world-class MBA and multiple Master of Science programs in both leading and emerging fields spanning accounting, finance, analytics, and technology. With a graduate degree from Bentley, students are prepared to lead, succeed, and become a force for positive change.

The Graduate Admission Office accepts applications from prospective students all over the world. When students apply for graduate programs, they often enclose a cover letter in their applications to express their interest in attending Bentley and highlight their credentials (e.g., backgroud, work experience, and undergraduate GPA).

You will write a program to help Graduate Admission officers pre-process the cover letters  of applicants. You will use your knowledge about Python strings and functions to reformat the body text of a cover letter, extract important information, and generate a report.

Input and Output

The program expects the user to enter two inputs:

· The line justification (Left, Right, Center).

· The line width ([30-80]).

Your program will process the cover letter and generate the following outputs:

· The reformatted cover letter text. As some officers like to read the cover letters off their cellphone screens, the program needs to reformat the cover letter with the user specified line width (30-80 characters long) and the line justification (Left, Right, or Center). See the outputs in the sample runs.

· A list of the title words that appear in the cover letter. A title word is a word with only the first letter capitalized and the rest of the letters in lowercase. Title words often are candidates for named entities (e.g., person names, organizations, locations, etc.).

· A report about some stats of the cover letter, including the number of paragraphs, number of sentences, number of words, average sentence length, and average word length. These stats often are indicators of the writing style and quality.

· Information about the applicant, including the grad program applied for, GPA, phone number, and email address.

Implementation

A starter file, coverletter-starter.py, is provided for you to begin with. Rename it as coverletter.py.

A Python file, parameters.py, is provided, which has two variables: The first variable, lettertext, is a long string containing the body text of a cover letter. The second variable, gradprograms, is a list of strings, which represent the graduate programs at Bentley (e.g., ‘MBA’, ‘MSA’, ‘MSBA’). You will import this program into your coverletter.py and just use the two variables. See the starter program for details.

Your program must implement several functions to complete various tasks:

· validCheck(just,width): This function takes the justification and the width values from the main program and returns a valid justification letter (‘L’, ‘R’, or ‘C’) and a valid integer width.

· removepunc(word): This function removes any punctuation before or after a word, but not in the middle (e.g., ‘(MBA)’ becomes ‘MBA’, ‘University.’ becomes ‘University’, but ‘3.75’ remains ‘3.75’) and returns the clean word. The string library contains a constant, punctuation, which is a list of punctuation marks. The starter file has already imported the string library. You can just use the constant directly. If you’d like to see what punctuation marks are included, simply use print(punctuation) to print them out.

· printpara(paragraph, just, width): This function reformats a single paragraph and prints out the result based on user requirements: left-, right-, or center-justified within the line width.

· isphone(word): This function returns True if the word is like DDD-DDD-DDDD, where the Ds are digits, False otherwise.

· isemail(word): This function returns True if the word is an email address and False otherwise.

· main(): The main() function will prompt the user to enter an integer between 30 and 80, inclusive, or to simply press the Enter key to use the default line width, 80. An error message is printed if the input is outside the range.  It will also prompt the user to enter the line justification (LRC), in either upper- or lower-case. The user can simply press the Enter key to use the default left justification. If the user enters anything other than L, R, C, or the Enter key (an empty string), the program will indicate that it is an invalid input and ask the user to retry.

The rest of the function puts everything together and produces the required output.

Requirements

· Find more format requirements in the sample runs at the back of this file.

· The Title Word section must use the same line justification and width as the cover letter text.

· The Report section must be divided into two columns with the first column right justified and the second column left justified. See examples.

· If a cover letter contains GPA, you must extract the GPA value.

· Floating-point numbers must be formatted appropriately using two decimal places.

· You must make your program general enough to be able to process different cover letters. When testing your program, different text strings (i.e., cover letters) will be used.

· You are prohibited from using any other Python libraries or concepts that were not covered in this class when this was assigned.

hints

· A paragraph ends with the newline character ‘\n’.

· A sentence ends with a period sign ‘.’

· Use the istitle() method to test whether a string is a title word.

· The printpara() function needs to build a line word by word (while testing if the line length is still shorter than or equal to the line width) and print out one line a time. You may implement the printline() function to print a single line with the required justification.

· Every time when a new title word is found, it has to be added to the list named titlewords. Use titlewords.append(word) to add the title word to the list.

· When printing the Title Words section, you can glue the individual words in the titlewords list together using the join()method for strings to build a string (or paragraph) and call the printpara() function to print the string out.

· A GPA value (e.g., 3.75) often appears within three words before or after the string “GPA”. For example, the text could be “My undergraduate GPA is 3.75”, “GPA: 3.75”, “3.75 GPA”, etc.

Submission

Test your program to make sure it works. Submit coverletter.py file on Brightspace. Please submit the parameter file.

Grading

• This assignment will be worth 10 percent toward your course grade.

• Your program should compile without syntax errors to receive any credit. If a part of your program is working, you will receive partial credit, but only if the program compiles without syntax errors. Your grade will be zero on this assignment if it contains any syntax errors.

Rubrics

Points

1

Prompt the user for line justification and width and correctly handle errors

10

2

Reformat and print the cover letter text with the correct justification and line width

20

3

Extract all title words and print them out properly

10

4

Correctly calculate the stats

10

5

Correctly extract the applicant information (e.g., program, GPA, phone, email)

20

6

Format the output properly (same as the samples)

10

Total

80

Sample Runs

This section shows what the output of your program might look like. Values entered by the user are in green (or blank).


Sample Run #1

============================= Cover Letter Program =============================
Output line width ([30, 80]), press Enter for 80:
Output justification (L/R/C), press Enter for L:
================================================================================
My name is John Smith. I am pleased to submit my application to the Master of
Science in Business Analytics (MSBA) program at Bentley University. Given my
previous academic background, a BA in Data Science from Northeastern University
with a 3.75 GPA, the MSBA program at Bentley with its focus on applications of
analytical methods in business and healthcare is a perfect fit for me to expand
my expertise and make a step forwards my goal of becoming a business analyst and
specialist.
Enclosed please find my resume and other supporting documents, required by the
Graduate Admissions Office. Please feel free to contact me at [email protected]
or 978-456-3747 if you have any questions. I look forward to hearing from you.
================================================================================
--------------------------------- Title Words ---------------------------------
John Smith Master Science Business Analytics Bentley University Data Science
Northeastern University Bentley Graduate Admissions Office

-------------------- Report --------------------
# paragraphs: 2
# sentences: 6
# words: 120
Average sentence length: 20.0
Average word length: 4.94
Program applied for: MSBA
GPA: 3.75
Phone: 978-456-3747
Email: [email protected]
------------------------------------------------


Sample Run #2

============================= Cover Letter Program =============================
Output line width ([30, 80]), press Enter for 80: 100
Line width must be between 30 and 80!
Output line width ([30, 80]), press Enter for 80: 80
Output justification (L/R/C), press Enter for L: u
Invalid input!
Output justification (L/R/C), press Enter for L: r

================================================================================
My name is John Smith. I am pleased to submit my application to the Master of
Science in Business Analytics (MSBA) program at Bentley University. Given my
previous academic background, a BA in Data Science from Northeastern University
with a 3.75 GPA, the MSBA program at Bentley with its focus on applications of
analytical methods in business and healthcare is a perfect fit for me to expand
my expertise and make a step forwards my goal of becoming a business analyst and
specialist.

Enclosed please find my resume and other supporting documents, required by the
Graduate Admissions Office. Please feel free to contact me at [email protected]
or 978-456-3747 if you have any questions. I look forward to hearing from you.

================================================================================

--------------------------------- Title Words ---------------------------------
John Smith Master Science Business Analytics Bentley University Data Science
Northeastern University Bentley Graduate Admissions Office


-------------------- Report --------------------
# paragraphs: 2
# sentences: 6
# words: 120
Average sentence length: 20.0
Average word length: 4.94

Program applied for: MSBA
GPA: 3.75
Phone: 978-456-3747
Email: [email protected]
------------------------------------------------


Sample Run #3

=================== Cover Letter Program ===================
Output line width ([30, 80]), press Enter for 80: 60
Output justification (L/R/C), press Enter for L: c

============================================================
My name is John Smith. I am pleased to submit my application
to the Master of Science in Business Analytics (MSBA)
program at Bentley University. Given my previous academic
background, a BA in Data Science from Northeastern
University with a 3.75 GPA, the MSBA program at Bentley with
its focus on applications of analytical methods in business
and healthcare is a perfect fit for me to expand my
expertise and make a step forwards my goal of becoming a
business analyst and specialist.

Enclosed please find my resume and other supporting
documents, required by the Graduate Admissions Office.
Please feel free to contact me at [email protected] or
978-456-3747 if you have any questions. I look forward to
hearing from you.

============================================================

----------------------- Title Words -----------------------
John Smith Master Science Business Analytics Bentley
University Data Science Northeastern University Bentley
Graduate Admissions Office


-------------------- Report --------------------
# paragraphs: 2
# sentences: 6
# words: 120
Average sentence length: 20.0
Average word length: 4.94

Program applied for: MSBA
GPA: 3.75
Phone: 978-456-3747
Email: [email protected]
------------------------------------------------