To begin, define the following methods for your StringUtility class: StringUtility def . . def O O O _init__(self, strin

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
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

Post by answerhappygod »

To Begin Define The Following Methods For Your Stringutility Class Stringutility Def Def O O O Init Self Strin 1
To Begin Define The Following Methods For Your Stringutility Class Stringutility Def Def O O O Init Self Strin 1 (190.96 KiB) Viewed 57 times
To begin, define the following methods for your StringUtility class: StringUtility def . . def O O O _init__(self, string) The init_() takes a string as a parameter and stores it as an instance variable. All methods will operate on this string, but only return a modified copy of the altered string. You should not overwrite the original string. _str_(self): return the internal string itself, unchanged
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'. ■
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply