# Week 9 practice problems, by chaynes@indiana.edu def emphasize(string): """ Return a string with the characters in the given string separated by spaces and all upper case. >>> emphasize('The Knights said Ni!') 'T H E K N I G H T S S A I D N I !' >>> """ # Hint: recall the string method upper() #. #. #. #. #. #. def whats_it_return(): """ >>> whats_it_return() #... >>> """ i = 0 s = '[812]123-4567' while i <= 10: if s[i:].isdigit(): return i i = i + 1 return -1 def surname_first(name): """ Takes a name string of the form " " and returns a string of the form ", ". >>> surname_first("John Cleese") 'Cleese, John' >>> """ #. #. def given_name_first(name): """ Takes a name string of the form ",", where may be any number (possibly zero) of spaces, and returnsa string of the form first_name last_name. >>> given_name_first("Cleese,John") 'John Cleese' >>> given_name_first("Cleese, John") 'John Cleese' >>> """ #. #. def inches(length): """ Return the number (an integer) of inches in the length string measurement.. Assume the string format is '[], where and are both non-empty sequences of digits, and is optional. >>> inches("1'3") # one foot three inches 15 >>> inches("2'") # two feet 24 >>> """ #. #. #. #. #. #. def minutes(time): """ Return the number of minutes indicated by the time string, which is in the format [h]h:mm, that is, there are one or two hour digits followed by a colon and two minutes digits. The maximum number of hours and minutes are 99 and 59, respectively. Return -1 if the time is not in this format. >>> minutes('2:05') 125 >>> minutes('10:58') 658 >>> minutes('123:45') -1 >>> minutes('2:60') -1 >>> minutes('255') -1 >>> minutes('-3:23') -1 >>> """ # Hint: the string method isdigit() returns true only if the string contains # only digits. #. #. #. #. #. #. #. #. #. def military_time(standard_time): """ Return the time represented by the string standard_time in the military time form 'hhmm', where s is in the form '[h]h:mm AM' or '[h]h:mm PM', and the hours and minutes are in the ranges 1 to 12 and 0 to 59, resp. Return None if standard_time is not in one of these forms. Note: the following tests are far from inclusive. >>> military_time('8:40 PM') '2040' >>> military_time('4:10 AM') '0410' >>> military_time('12:30 AM') '0030' >>> military_time('12:00 PM') '1200' >>> military_time('1230 PM') >>> # None returned """ #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #. #.