Due: Monday, February 22, 2019 at 11:55 p.m — note extension
- (40 points) A string is said to be reverse alphabetic if the letters in it, regardless of case, are in the reverse of dictionary order. So, for example, “miff” and “pooka” are reverse alphabetic, and “willow” and “computer” are not.
- Write a recursive function called isrevalpha(s) that returns True if s contains a string that is reverse alphabetic, and False otherwise. The function must ignore any non-letter characters in s, and treat all alphabetic characters as lower case. Note the function must be recursive, and so must call itself.
- Write a program that reads a string and uses the above function to determine whether the string is reverse alphabetic. The program is to loop until the user types an end of file (control-D), or another exception occurs.
Here is sample output:
The string? heLlo↵
heLlo is not reverse alphabetic
The string? miff↵
miff is reverse alphabetic
The string? t^p(m*j+e↵
t^p(m*j+e is reverse alphabetic
The string? cOmPuTeR↵
cOmPuTeR is not reverse alphabetic
The string? EdCb+++a↵
EdCb+++a is reverse alphabetic
The string? control-D
- (60 points) The file “data_hw_3” contains lines with 3 columns separated by a space representing the volume of air inspired and expired. The first column is the breath number (BN); the second column is the volume of air inspired, in ml; and the third column of air is the volume of air expired.
Write a program that computes the average, standard deviation, maximum difference between air inspired and expired for each breath, and the minimum difference between air inspired and air expired for each breath. Your output should look like this (but with the correct numbers; the ones here are wrong):
Average volume of air inspired is 120.15 ml with a standard deviation of 328.90
Average volume of air expired is 121.82 ml with a standard deviation of 561.20
The maximum difference between air inspired and expired is 289
The minimum difference between air inspired and expired is 5
Department of Computer Science
University of California at Davis
Davis, CA 95616-8562 USA
Last modified: Version of February 5, 2019 at 7:25PM|
Winter Quarter 2019
You can get a PDF version of this