Python Programming
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.
You can place an order similar to this with us. You are assured of an authentic custom paper delivered within the given deadline besides our 24/7 customer support all through.
Latest completed orders:
# | topic title | discipline | academic level | pages | delivered |
---|---|---|---|---|---|
6
|
Writer's choice
|
Business
|
University
|
2
|
1 hour 32 min
|
7
|
Wise Approach to
|
Philosophy
|
College
|
2
|
2 hours 19 min
|
8
|
1980's and 1990
|
History
|
College
|
3
|
2 hours 20 min
|
9
|
pick the best topic
|
Finance
|
School
|
2
|
2 hours 27 min
|
10
|
finance for leisure
|
Finance
|
University
|
12
|
2 hours 36 min
|