Esempio n. 1
0
def testlw():
    test.testy(ch12ex.longestword(["a", "apple", "pear", "grape"]) == 5)
    test.testy(ch12ex.longestword(["a", "am", "I", "be"]) == 2)
    test.testy(
        ch12ex.longestword(["this", "supercalifragilisticexpialidocious"]) ==
        34)
    test.testy(ch12ex.longestword([]) == 0)
Esempio n. 2
0
def testew():
    test.testy(ch12ex.extract_words("hey!") == ["hey"])
    test.testy(ch12ex.extract_words("hey you") == ["hey", "you"])
    test.testy(
        ch12ex.extract_words(
            "Now is the time! 'Now', is the time? Yes, now.") ==
        ['now', 'is', 'the', 'time', 'now', 'is', 'the', 'time', 'yes', 'now'])
    test.testy(
        ch12ex.extract_words("she tried to curtsey as she spoke--fancy") ==
        ['she', 'tried', 'to', 'curtsey', 'as', 'she', 'spoke', 'fancy'])
Esempio n. 3
0
def testwc():
    test.testy(
        ch12ex.wordcount("now", ["now", "is", "time", "is", "now", "is", "is"])
        == 2)
    test.testy(
        ch12ex.wordcount("is", ["now", "is", "time", "is", "now", "the", "is"])
        == 3)
    test.testy(
        ch12ex.wordcount("time",
                         ["now", "is", "time", "is", "now", "is", "is"]) == 1)
    test.testy(
        ch12ex.wordcount("frog",
                         ["now", "is", "time", "is", "now", "is", "is"]) == 0)
Esempio n. 4
0
def testws():
    test.testy(
        ch12ex.wordset(["now", "is", "time", "is", "now", "is", "is"]) ==
        ["is", "now", "time"])
    test.testy(
        ch12ex.wordset(["I", "a", "a", "is", "a", "is", "I", "am"]) ==
        ["I", "a", "am", "is"])
    test.testy(
        ch12ex.wordset(["or", "a", "am", "is", "are", "be", "but", "am"]) ==
        ["a", "am", "are", "be", "but", "is", "or"])
Esempio n. 5
0
def testsn():
    test.testy(ch7ex.sum_neg([3, -4, -5, 6]) == 9)
Esempio n. 6
0
def testdn():
    print("now testing dn")
    test.testy(ch6ex.day_name((-1) == "string"))
Esempio n. 7
0
def testhd():
    test.testy(ch12ex.has_dash("distance--but"))
    test.testy(not ch12ex.has_dash("several"))
    test.testy(ch12ex.has_dash("spoke--"))
    test.testy(ch12ex.has_dash("-yo-yo-"))
Esempio n. 8
0
def testad():
    test.testy(ch11ex.add_vectors([1,2,3],[2,3,4])==[3,5,7])
Esempio n. 9
0
def testeo():
    test.testy(ch6ex.is_even(4) == True)
    test.testy(ch6ex.is_odd(4) == False)
Esempio n. 10
0
def testso():
    test.testy(ch7ex.sum_odd([3, 4, 5, 6]) == 3)
Esempio n. 11
0
def testcc():
    test.testy(ch8ex.count_char("a", "happy") == 1)
Esempio n. 12
0
def testcw():
    test.testy(ch12ex.cleanword("!dkdjd%") == "dkdjd")
    test.testy(ch12ex.cleanword("what?") == "what")
    test.testy(ch12ex.cleanword("'now!'") == "now")
    test.testy(ch12ex.cleanword("?+='w-o-r-d!,@$()'") == "word")
Esempio n. 13
0
def testrp():
    test.testy(ch8ex.rem_punct("hi!-You!") == "hiYou")
Esempio n. 14
0
def testce():
    test.testy(ch7ex.count_even([3, 4, 5, 6]) == 2)
Esempio n. 15
0
def testnd():
    print("now_testing nd")
    test.testy(ch6ex.name_day(("bad user input") == "not valid"))
Esempio n. 16
0
def testco():
    test.testy(ch7ex.count_odd([3, 4, 5, 6]) == 2)
Esempio n. 17
0
def testsqrt():
    test.testy(int(ch7ex.sqrt(30)) == 5)
Esempio n. 18
0
def testts():
    test.testy(ch7ex.to_sam(["happy", "sad", "sam", "r"]) == 2)
Esempio n. 19
0
def testsca():
    test.testy(ch11ex.scalar([1,2,3],4)==[4,8,12])
Esempio n. 20
0
def testmir():
    test.testy(ch8ex.mirror("god") == "goddog")
Esempio n. 21
0
def testrd():
    print("now testing rd")
    test.testy(ch6ex.return_day("sunday", 2) == "tuesday")
Esempio n. 22
0
def testwl():
    test.testy(ch7ex.word_length(["happy", "sad", "cools", "r"]) == 2)
Esempio n. 23
0
def testts():
    test.testy(ch6ex.to_seconds(2, 30, 10) == 9010)
Esempio n. 24
0
def testnew():
    test.testy(ch6ex.in_hours(9010) == 2)
Esempio n. 25
0
def testrev():
    test.testy(ch8ex.reverse("god") == "dog")
Esempio n. 26
0
def testhypot():
    test.testy(ch6ex.hypotenuse(3, 4) == 5.0)
Esempio n. 27
0
def testpal():
    test.testy(ch8ex.palin("god") == "no")
Esempio n. 28
0
def testcompare():
    test.testy(ch6ex.compare(5, 4) == 1)
Esempio n. 29
0
def testcl():
    test.testy(ch8ex.count_lett("na", "banana") == 2)
Esempio n. 30
0
def testcro():
    test.testy(ch11ex.cross_prod([1,2,3],[4,5,6])== [-3,6,-3])