This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # D. verbing | |
| # Given a string, if its length is at least 3, | |
| # add 'ing' to its end. | |
| # Unless it already ends in 'ing', in which case | |
| # add 'ly' instead. | |
| # If the string length is less than 3, leave it unchanged. | |
| # Return the resulting string. | |
| def verbing(s): | |
| if len(s) < 3: | |
| return s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A. donuts | |
| # Given an int count of a number of donuts, return a string | |
| # of the form 'Number of donuts: <count>', where <count> is the number | |
| # passed in. However, if the count is 10 or more, then use the word 'many' | |
| # instead of the actual count. | |
| # So donuts(5) returns 'Number of donuts: 5' | |
| # and donuts(23) returns 'Number of donuts: many' | |
| def donuts(count): | |
| if count >= 10: | |
| return 'Number of donuts: many' |