NA AK – Python programming week 4

Submission Requirements:
• One Word document (the file name must be Lab4B.docx) containing:
o Screenshots: the testing and outputs of the execution of your Python programs.
o Copies of your Python programs: no images/screenshots of your code! The
copies must be in “text” format.
o Important:
▪ your testing screenshots must include the sample testing cases shown
below and another testing case of yours.
▪ Items in this Word document must be in the same order as the questions.
• Your Python programs (that is, the .py program files)—note that there are specific
requirements on the program names:
o Your code must be properly commented (like the examples in Code Archive; you
don’t have to comment on every line of code.)
o On the top of your program, there must be 3~5 lines of the comments with your
full name and date/time when you have completed the programs.
• (Attach/submit/upload the Word file and your program files individually; do not zip the
programs.)
Q1 (60 points) Write a program “Lab4B01.py” that prompts the user to enter a string and then:
1. Display the length of the string.
2. Convert all the vowels into lowercase and display the modified string.
3. Display a count of each of the vowels and the total number of vowels in the string.
4. Convert the string into list of words and display the length of the list.
(Note: the input vowels may be either uppercase or lowercase letters.)
The screenshot of your program execution would look like the following:
2
Q2 (60 points) Write a program “Lab4B02.py”that keeps prompting the user (until input of 0)
for a distance in meters and then displays that distance converted to miles, feet and inches*.
Please note that the value to be converted to feet in this problem is the decimal portion of the
number of miles, and the value to be converted to inches is the decimal portion of the number
of feet. It is not sufficient to simply convert the entire distance in meters to miles, feet and
inches, respectively. HINT: use can use the Python int() function to return the decimal portion
of your calculation for miles, feet and inches. Test with 5000 meters. Show that result in your
screenprint.
*1 meter = 0.000621371 miles. 1 mile = 5280 feet. 1 foot = 12 inches

Powered by WordPress