Consider the following equations:
SEVEN PLUS TWO = EIGHTEEN MINUS NINE = EIGHTEEN OVER TWO
That's true enough on its face. But Susan Thorpe discovered that if each letter is replaced with the number of its position in the alphabet (A=1, B=2, C=3, …), then the equivalence persists — the values in each of the three phrases total 191.
Write a function character_value that takes a single character (str). The function must return the value (int) of the character. The value of a letter corresponds to its position in the alphabet (A=1, B=2, C=3, …). The value of any other character is 0.
Write a function string_value that takes a string (str). The function must return the value (int) of the string. This value is computed as the sum of the values of all characters in the string.
Write a function istantamount that takes two strings (str). The function must return a Boolean value (bool) that indicates whether the two strings have the same value.
Write a function isequality that takes a string (str). The function must return a Boolean value (bool) that indicates whether the string is an equality. This is the case if the following two conditions hold:
the string contains a single equal sign (=)
the left-hand side (the string before the equal sign) has the same value as the right-hand side (the string after the equal sign)
None of these functions may make a distinction between uppercase and lowercase letters.
>>> character_value('A')
1
>>> character_value('z')
26
>>> character_value('!')
0
>>> string_value('SEVEN PLUS TWO')
191
>>> string_value('eighteen minus nine')
191
>>> string_value('Eighteen Over Two')
191
>>> string_value('Tea For Two')
123
>>> istantamount('SEVEN PLUS TWO', 'eighteen minus nine')
True
>>> istantamount('eighteen minus nine', 'Eighteen Over Two')
True
>>> istantamount('SEVEN PLUS TWO', 'Tea For Two')
False
>>> isequality('SEVEN PLUS TWO = eighteen minus nine')
True
>>> isequality('eighteen minus nine=Eighteen Over Two')
True
>>> isequality('SEVEN PLUS TWO = eighteen minus nine = EIGHTEEN OVER TWO')
False
>>> isequality('SEVEN PLUS TWO ~ eighteen minus nine')
False
>>> isequality('SEVEN PLUS TWO = Tea For Two')
False