from rt import *
###################### Problem 1 ############################
def count_words(s):
"""
count_words("I eat cake") -> 3
count_words("") -> 0
count_words("To be or not to be, that is the question.") -> 10"""
return 0
###################### Problem 2 ############################
def space_cadet(ch, s):
""" ch is a character, and s is a string
return a string that repplaces every instance of ch
with a spoace. This shuould be case SENSITIVE.
example: space_cadet("a", "panorama") ->"p nor m "
"""
return ""
###################### Problem 3 ############################
def same_letters(word1, word2):
"""
return True if the two words have exactly the same
set of letters (ignore repeats), case insensitive.
same_letters("scatter", "smatter") -> False
same_letters("fail", "FLAIL") -> True
"""
return False
###################### Problem 4 ############################
def ordered_list(items):
"""items is a list of strings.
returns a string with an HTML ordered list.
example:
ordered_list("cows", "horses", "pigs") ->
- cows
- horses
- pigs
You can use a triple-quoted string or whack-ns to achieve
the newline effect"""
return ""
###################### Problem 5 ############################
def is_perfect(n):
"""
n is a positive integer and n >= 2
n is perfect if it is the sum of its proper divisors.
6 has proper divisors 1,2,3 so is_perfect(6) -> True
12 has proper divisors 1,2,3,4,6, which sum to 22,
so is_perfect(12) -> False
Hint: You might want to write a helper function
sum_of_proper_divisors(n)
"""
return False
###################### Problem 6 ############################
def lurks_in(word, search_field):
"""
word is a string of letters
search_field is a string
returns True if the letters in word can be found in
order in the string search_field. This is case-insensitive
lurks_in("abcd, "abcessed") -> True
lurks_in("foot, "flounder of trust") -> True
lurks_in("dequeue", "defend the queen") -> False"""
return False
def main():
print("***************Test Problem 1************")
s = "I eat cake"
test = [s]
expected = 3
run_test(count_words, expected, test)
s = ""
test = [s]
expected = 0
run_test(count_words, expected, test)
s = "To be or not to be, that is the question."
test = [s]
expected = 10
run_test(count_words, expected, test)
print("***************Test Problem 2************")
print("***************Test Problem 3************")
print("***************Test Problem 4************")
print(ordered_list(["cats", "dogs", "elephants", "ferrets"]))
print("***************Test Problem 5************")
print("***************Test Problem 6************")
main()