To begin, define the following methods for your StringUtility class: StringUtility def . . def O O O _init__(self, strin
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
To begin, define the following methods for your StringUtility class: StringUtility def . . def O O O _init__(self, strin
Making a library You will use the string features described above to complete all the methods in the driver code given to you. You will need to add the following methods to your StringUtility class: def vowels (self): . Count the number of vowels in the string, and return a new string of the form '<count>', where <count> is the number of vowels in the string as a string However, if the count is 5 or more, then return the word 'many' instead of the actual count. So "Binghamton" returns 3' and "Incomprehensibilities" returns 'many' def bothEnds (self): return a string made of the first 2 and last 2 chars of the original string, so 'spring' yields 'spng'. However, if the string length is less than or equal to 2, return an empty string instead. def fixstart (self): O D return a string where all occurrences of its first char have been changed to ** _except do not change the first char itself. e.g. 'babble' yields "ba**le". If the parameter is length 1 or less, return the parameter as is. def asciisum(self): O return an integer that is the sum of all ascii values in the string. def cipher (self): D return an encoded string by incrementing all letters by the length of the string. You should leave any characters that are not letters unchanged. ■ For example, the string "Dog" would be shifted by 3, resulting in "Grj", while "Horse" would become "Mtwxj" because it shifts by 5 characters. You must account for wrap around (z=>a). Uppercase always wraps around to upper case, and lowercase always wraps around to lower case. For example, Z+2 should be 'B', while y+3 should be 'b'. ■