Reference no: EM132360745
Part 1 : String Manipulation
For this part, your group will be creating 4 functions.
Question 1
Write a function called backwards that takes in one string as a parameter. The function return a new string. The returned string should just be the original string, but in reverse order.
Examples:
>>> a = backwards("School")
>>> print(a) loohcS
>>> b = backwards("cat")
>>> print(b) tac
Question 2
Write a function called abbreviator that takes in one string as a parameter. The function should return a new string. The returned string should contain only the capital letters and numbers from the original string. Make sure that your returned string does not contain any special characters such as periods, semicolons, apostrophe's, spaces, etc.
(Hint: the isalpha() and isupper() functions may help)
Examples:
>>> a = "If You're Reading This It's Too Late"
>>> b = abbreviator(a)
>>> print(b)
IYRTITL
>>> c = "Hotline Sling part 2"
>>> d = abbreviator(c)
>>> print(d)
HB2
Part 2
Question 1
Write a function called evenOdd that takes in a list of random elements. This function should return a new string. For every string located at an even position within the list (count the Oth index as even), you will take the first vowel (a,e,i,o,u) out of the string and add it to the new string. For every string located at an odd position in the list, you will take first consonant out of the string and add it to the string. Treat y as a consonant. The returned string must be all lowercase. Do not process non- strings elements and ignore characters in strings that are not letters. Examples:
>» a = evenOdd(['car, 'Dog', False, 9, 'treat']) >>> print(a)
ade
>>> b = evenOdd(['Perfume', 'Kyary', 'pon-pon', True, None])
>>>print(b)
eko
Question 2
Write a function called parse that takes in two parameters: a string and a delimiter. Your function should return a list of separated strings depending on the delimiter. You may assume the delimiter will be a single character. Each string in the list should not contain the delimiter itself. You may not use any built-in Python functions such as the split function, instead, use iteration and conditionals.
Examples:
parse("This is a Sentence", " ") should return ['This', 'is', 'a', 'Sentence']
parse("f-r-i-e-n-d-s", "-") should return [1, 'r', 'P, 'e', 'n', 'd', 's']
parse("f,.5,.5",",") should return ['f', '.5',
parse("f„.5",",") should return [ ", (The 2nd element Is an empty
string).