CS170 File String
CS170 File String
In this lab, we would like to process the input string values that we read from files. In addition, we
would like to store the processed results of a program by writing the contents to a file.
Purpose:
Reading input from a file and writing the processed results to a file are immensely helpful. In
addition, processing the input text values by using string library functions are something that we are
interested to understand, practice, and learn in this assignment.
>> Deliverable 1: Modify the function countChars to count number of digits in the line of text. Use
the function and read from a file one line at a time and count the total number of digits that we have
in the file. The input file for this program is named "wordNumbers.txt".
Sample Input (assume the content of the wordNumbers.txt file is the following:)
The word "hundred" is actually derived from the Old Norse word "hundrath,"
which actually means 120, not 100.
More specifically, "hundrath," in Old Norse, means "long hundred,"
which equals 120, due to the duodecimal system.
But good luck trying to argue that your $100 bill is worth 20 percent more
than it is.
Sample Output (the following output will be written in the areaPerimeter.txt file)
The file has 14 digits
Problem 2: All uppercases [1 program + 1 screenshot]
Lab Problem: [save the program as: convertUpperCase.py]
In this program, read line of texts from an input file and convert the line of texts into uppercases and
save it in an output file. We have demonstrated a function called convertCase that takes a line of text
as a parameter and returns the it in all lowercases. You can modify this function and use it to read
from an input file named "lowercases.txt" and create an output file named "uppercases.txt".
>> Deliverable 2: You can take advantage of the function and modify it for this program. Read line
of texts from an input file one line at a time. After reading the line, convert it into all uppercase.
Further, write the line to an output file.
Sample Input (assume the content of the lowercases.txt file is the following:)
I can't change the direction of the wind,
but I can adjust my sails to always reach my destination.
Sample Output (the following output will be written in the uppercases.txt file)
I CAN'T CHANGE THE DIRECTION OF THE WIND,
BUT I CAN ADJUST MY SAILS TO ALWAYS REACH MY DESTINATION.
You may assume there are no errors in the input. As previously noted, please use only the features of
the language taught in the class. Please let me know if you have any further questions.
The deadline to submit the lab is: 11:59pm, Monday 15 July. Please let me know if you
have any further questions. Thank you.
Rubrics
When you are satisfied with your work, submit all three of the Python program files
(convertUpperCase.py, countDigits.py) and 2 screenshots on the Blackboard course website.