Let’s call a word a "downword" if its letters are alphabetically sorted, case-insensitively, right to left. By this definition,
Pond is a downword because
d comes before
n, which comes before
o, which comes before
P. So too is
oo does not violate this definition), but
lake is not because neither
k comes before
Answer the below in
(1 point.) Is
(1 point.) Is
(2 points.) Recall from the test that we called a word an "upword" if its letters are alphabetically sorted, case-insensitively, left to right. Consider the below implementation in Python of
upword, a function that returns
str) is an upword and
Falseif it is not. Assume that
downwordis a function (implemented elsewhere) that returns
wordis a downword and
Falseif it is not.
def upword(word): return not downword(word)
Is this implementation of
upwordcorrect? Explain why or why not.
(4 points.) Assume now that
downwordhas not (yet!) been implemented elsewhere. Complete the implementation of
downword, below, in such a way that it returns
Trueif and only if
str) is a downword. Return
wordcontains one or more non-alphabetical characters or if the letters in word are not alphabetically sorted, case-insensitively, right to left.
def downword(word): # TODO
Which resources, if any, did you find helpful in answering this problem’s questions?
About how long did you spend on this problem’s questions?