Assignment Rules: Open book and notes assignment This homework tests your knowledge of File Handling, use of String methods, and use of Sets. A
Assignment Rules:
Open book and notes assignment
- This homework tests your knowledge of File Handling, use of String methods, and use of Sets.
- Adhere to the naming conventions discussed in class for variable names, program name and function names
- Use meaningful names for variables, functions etc
- If there are two words in the variable use first word lowercase and first letter of second word upper case i.e., firstName or underscore between 2 words i.e first_name
- Include appropriate comments in the code
- Output should be displayed similar to as mentioned against each problem
- Indent the lines of code appropriately
1. char_analysis.py (40 points)
Write a program that reads the file's contents and determine the following:
- The number of Uppercase letters in the file
- The number of Lowercase letters in the file
- The number of digits in the file
- The number of whitespace characters in the file
HINTS:
Define main():
Declare Local variables
Open file text.txt for reading. Use 'text.txt' file available under the Modules section in Canvas.
Use for loop to step through each character in the file.
Determine if the character is uppercase, lowercase, a digit, or space, and keep a running total of each.
Close the file.
Display the totals of uppercase, lowercase, digits, spaces.
Sample Output:
Uppercase letters: 29
Lowercase letters: 1228
Digits: 30
Spaces: 260
2. unique.py (30 points)
Write a program that opens a specified text file (text2.txt) and displays a list of all unique words found in the file.
HINTS:
Define main():
Declare Local variables
Open file text2.txt for reading. Use 'text2.txt' file available under the Modules section in Canvas.
Use 'set' method to find the unique words in the file and store each of them as an element of the set.
Close the file.
Display all the unique words from the set.
Sample output:
These are the unique words in the text:
management.
name
been
later,
canceled,
is
Eastern,
delay
Eight
1,820
at
it
1867
official
world
and
company,….
3. name.py (30)
Write a program that gets a string containing a person's first, middle, and last names, and displays their first, middle, and last initials. For example, if the user enters Susan Smith Miller, the program should display S.S.M.
Define main():
Declare Local variables
Prompt user to enter the full name
Use 'split' method to split the full name
Use for loop to get first character of each name as an initial
Convert the first character to upper case if it is already not in upper case
Display output
Sample output:
Enter your full name: Susan Smith Miller
S.S.M.
No one is unaware of the name of that famous English shipowner, Cunard. In 1840 this shrewd industrialist founded a postal service between Liverpool and Halifax, featuring three wooden ships with 400-horsepower paddle wheels and a burden of 1,162 metric tons. Eight years later, the company's assets were increased by four 650-horsepower ships at 1,820 metric tons, and in two more years, by two other vessels of still greater power and tonnage. In 1853 the Cunard Co., whose mail-carrying charter had just been renewed, successively added to its assets the Arabia, the Persia, the China, the Scotia, the Java, and the Russia, all ships of top speed and, after the Great Eastern, the biggest ever to plow the seas. So in 1867 this company owned twelve ships, eight with paddle wheels and four with propellers. If I give these highly condensed details, it is so everyone can fully understand the importance of this maritime transportation company, known the world over for its shrewd management. No transoceanic navigational undertaking has been conducted with more ability, no business dealings have been crowned with greater success. In twenty-six years Cunard ships have made 2,000 Atlantic crossings without so much as a voyage canceled, a delay recorded, a man, a craft, or even a letter lost. Accordingly, despite strong competition from France, passengers still choose the Cunard line in preference to all others, as can be seen in a recent survey of official documents. Given this, no one will be astonished at the uproar provoked by this accident involving one of its finest steamers.
,
No one is unaware of the name of that famous English shipowner, Cunard. In 1840 this shrewd industrialist founded a postal service between Liverpool and Halifax, featuring three wooden ships with 400-horsepower paddle wheels and a burden of 1,162 metric tons. Eight years later, the company's assets were increased by four 650-horsepower ships at 1,820 metric tons, and in two more years, by two other vessels of still greater power and tonnage. In 1853 the Cunard Co., whose mail-carrying charter had just been renewed, successively added to its assets the Arabia, the Persia, the China, the Scotia, the Java, and the Russia, all ships of top speed and, after the Great Eastern, the biggest ever to plow the seas. So in 1867 this company owned twelve ships, eight with paddle wheels and four with propellers.
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.