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

Fall 2023

Due 11:59 PM on Monday, October 30, 2023

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 & 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. Since 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. Points will betaken off if you don’t follow this naming requirement. This rule will also apply for all future assignments and work.

•    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:

o validjust(): This function prompts 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 function returns a valid justification letter (‘L’, ‘R’, or ‘C’).

o validwidth(): This function prompts 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. The function returns a valid integer width.

o 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’dlike to see what punctuation marks are included, simply use print(punctuation) to print    them out.

o 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.

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

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

o main(): The main() function will put everything together and produces the required output.

REQUIREMENTS

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

•    The Title Words section must use the same line justification and width as for 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 packages (e.g., re, nltk) that are not covered in this class.

•    The use of artificial intelligence programs to generate code or other content is strictly

prohibited. You will receive a grade of 0 and an Academic Integrity Violation for any assignments that appear to be produced using AI tools.

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 printout one line a time. You may implement

the printline() function to print a single line with the required justification.

•    Everytime 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.

Do not submit the parameter file.

GRADING

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

•    Your program will be tested by a computer program before I evaluate it. The tester program is not intelligent enough to interpret the output. Therefore, for full credit, the input and output of your program need to appear in exactly the order shown in the sample runs. Otherwise, it will break the testing program and points will be deducted from your grade.

•    Your program should compile without syntax errors to receive any credit. If apart 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