!pip install ipython_doctester from ipython_doctester import test import ipython_doctester ipython_doctester.workshop_name = '' ipython_doctester.verbose = True ipython_doctester.student_name = '' @test def happyBirthday(name): ''' >>> happyBirthday('Jessica') 'Happy Birthday Jessica!' >>> happyBirthday('Adam') 'Happy Birthday Adam!' >>> happyBirthday('Liz') 'Happy Birthday Liz!' ''' @test def cube(i): ''' >>> cube(1) 1 >>> cube(2) 8 >>> cube(3) 27 ''' @test def tooLongForTwitter(myString): ''' >>> tooLongForTwitter('The Analytical Engine weaves algebraic patterns, just as the Jacquard loom weaves flowers and leaves.' + ... '-- Ada Lovelace, the first programmer') False >>> tooLongForTwitter('Four score and seven years ago our fathers brought forth on this continent a new nation, ' + ... 'conceived in liberty, and dedicated to the proposition that all men are created equal.') True >>> tooLongForTwitter('They told me computers could only do arithmetic. -- Computer pioneer Grace Hopper') False ''' @test def multiplyString(myString, numRepetitions): ''' >>> multiplyString('a', 4) 'aaaa' >>> multiplyString('Hello', 2) 'HelloHello' >>> multiplyString('Python', 3) 'PythonPythonPython' ''' @test def checkNickname(nickname, firstname): ''' >>> checkNickname('jess', 'jessica') True >>> checkNickname('bill', 'william') False >>> checkNickname('liz', 'elizabeth') True ''' @test def greatest(x, y, z): ''' >>> greatest(3, 9, 6) 9 >>> greatest(0.5, 0.25, 0) 0.5 >>> greatest(4, 5, 5) 5 ''' @test def menuSpecials(vegetable, entree): ''' >>> menuSpecials('asparagus', 'pasta primavera') 'Today our specials are: asparagus and pasta primavera' >>> menuSpecials('artichoke', 'steak frites') 'Today our specials are: artichoke and steak frites' >>> menuSpecials('kale', 'fondue') 'Today our specials are: kale and fondue' ''' @test def enoughLadybugs(ladybugs, trees): ''' >>> enoughLadybugs(300, 3) True >>> enoughLadybugs(300, 4) False >>> enoughLadybugs(250, 11) False ''' @test def makeHTML(tag, word): ''' >>> makeHTML('i', 'Test') 'Test' >>> makeHTML('b', 'Important!') 'Important!' >>> makeHTML('code', 'variable') 'variable' ''' @test def returnFirstItem(myList): ''' >>> >>> returnFirstItem(['a', 'b', 'c']) 'a' >>> returnFirstItem([4.5, 72, -1, 6]) 4.5 >>> returnFirstItem(['Hermione', 'Ron', 'Harry']) 'Hermione' ''' @test def addExclamation(myList): ''' >>> addExclamation(['alpha', 'beta']) ['alpha', 'beta', '!'] >>> addExclamation(['Jessica', 'likes', 'ice cream']) ['Jessica', 'likes', 'ice cream', '!'] >>> addExclamation(['?', '#', '$']) ['?', '#', '$', '!'] ''' @test def findStudent(name, studentList): ''' >>> findStudent('Wanda', ['Henry', 'Beatrice', 'Wanda', 'Evan']) True >>> findStudent('Adam', ['Tanya', 'Alice', 'Sean']) False >>> findStudent('Jen', ['Jessica', 'Jessie', 'Jerry', 'Jen']) True ''' @test def getFirstQWord(wordList): ''' >>> getFirstQWord(['quail', 'quetzal', 'quizzical']) 'quail' >>> getFirstQWord(['croissant', 'quiche', 'toast']) 'quiche' >>> getFirstQWord(['zip', 'blip', 'quip']) 'quip' ''' @test def countFs(phrase): ''' >>> countFs('Finished files are the result of years of scientific study combined with the experience of years.') 6 >>> countFs('Four score and seven years ago') 1 >>> countFs('A man, a plan, a canal - Panama!') 0 ''' @test def startsOrEndsWithZ(myString): ''' >>> startsOrEndsWithZ('pizzazz') True >>> startsOrEndsWithZ('python') False >>> startsOrEndsWithZ('zap') True ''' @test def sumOfAllStrings(stringList): ''' >>> sumOfAllStrings(['Eleanor', 'Rigby']) 12 >>> sumOfAllStrings(['Eight', 'Days', 'a', 'Week']) 14 >>> sumOfAllStrings(['Strawberry', 'Fields', 'Forever']) 23 ''' @test def stretchString(myString, stretch_number): ''' >>> stretchString('banana', 2) 'bbaannaannaa' >>> stretchString('apple', 3) 'aaappppppllleee' >>> stretchString('fig', 4) 'ffffiiiigggg' ''' @test def squaresList(numberList): ''' >>> squaresList([1, 2, 3]) [1, 4, 9] >>> squaresList([4, 0]) [16, 0] >>> squaresList([12, 9, 6, 3]) [144, 81, 36, 9] ''' @test def removeVowels(myString): ''' >>> removeVowels('bookkeeper') 'bkkpr' >>> removeVowels('almanac') 'lmnc' >>> removeVowels('syzygy') 'syzygy' ''' @test def removeWordsWithVowels(stringList): ''' >>> removeWordsWithVowels(['hymn','myth','myrrh','nymph']) ['hymn', 'myth', 'myrrh', 'nymph'] >>> removeWordsWithVowels(['who','what','when','where','why']) ['why'] >>> removeWordsWithVowels(['coy','sly','shy','bashful']) ['sly', 'shy'] ''' @test def spellingBee(correct, guess): ''' >>> spellingBee('hello', 'hello') 'correct' >>> spellingBee('python', 'pithon') 'almost' >>> spellingBee('echolocation', 'eckolocashun') 'wrong' '''