The function first_three takes one string parameter, word, and returnsaΒ slice of length three from the front of word.Β However, if word has length less than three, then the None object is returned instead.
The function slice_end takes a string parameter, word, and a positive integer n; the function returnsaΒ slice of length n from the end of word.Β However, if word has length less than n, then the None objectΒ is returned instead.
The function add_char_counts takes three parameters: a string s and two strings of length 1, char1 and char2, and returns the total number of times either char1 or char2 appears in s.
The function countWordsOfLength takes a list of words L and an integer n, and returns the total number of words of length n that appear in the list. For example, countWordsOfLength(["yes", "no", "maybe", "NNOOO"], 5) would return 2 because the given list has two words of length 5.
Hint: Use the accumulator pattern to solve this problem. Inside the for loop, use an ifstatement to only update the accumulator when the current word has length n.
The function make_abbreviation takes one parameter, wordlist, a list of words, and produces an acronym out of the words in the list, with a period after each initial character.Β The function returns the resulting acronym string.
The function count_contains_x takes a list of strings (wordList) and returnsthe count ofΒ how many strings in the list contain at least one upper- or lower-case βxβ.
The function remove_vowels takes one parameter, s, a string of any length. The function then returns a new string that contains all the letters in s except for the vowels: βaβ, βeβ, βiβ, βoβ, βuβ.
The function decodeFromAscii takes a list L of integers in the range 32 through 126. Each item in L is an ASCII code representing a single printable character. The function accumulates the string of characters represented by the list of ASCII codes and returns that string.
Note: ASCII was created in the 1960βs so programmers could have a standard encoding for common keyboard characters as numbers. It was later expanded to create Unicode so that characters from languagesΒ other than English, mathematical symbols, and many other symbols could also be represented by numerical codes.
The function concatAltChars takes a string parameter s and a boolean parameter even; the function concatenates together either the even-position characters of s or the odd-position characters of s, depending on whether even is True, or False, respectively. The accumulated string is returned.
For example, the even-indexed characters of "HANOVER" are at indexes 0, 2, 4, and 6:Β H N V R. So, concatAltChars("HANOVER", True)returns the string result "HNVR".
Hint: You can iterate over the positive indices i for characters in mystr: 1, 2, 3, ...., len(mystr)-1 with a for loop. For each i, if the character at index i matches the character at index i - 1, return True. Otherwise, if no doubled character is found in the entire string, return False.
Hint: Check the first three requirements with decision statements, then use a forloop to iterate over mystr and check the every character is a digit or a dot
The function find_max_char takes one string parameter, mystr. The function returns the character in mystr with the maximum ordinal value (the character that comes last in the ASCII alphabet, relative to the other characters in mystr).Β However, if mystr is the empty string, the function returns the Python object None.
Notice that we donβt need the ord() function to compare ordinal values; we can use comparison operators. For example, "Z" > "C" is true because Z comes after C in the ASCII alphabet.