The code should receive an input, and give out an output according to the assert equals tests, as described below.
Examples:
o 'hello' should output 'h tato'
o 'hello world' should output 'llo wollo wohello w tato'
o 'hello world!' should output 'llo worllo worhello wo tato'
o 'potato code test program.' should equal 'tato code test progrtato code test progrpotato code test prog tato'
HINT:
- It always ends with ' tato'
def PotatoCode(input):
output = input[2:len(input)-3]*2+str(input[:len(input)-4])+" tato"
return str(output)
# TODO: Replace examples and use TDD development by writing your own tests
# These are some of the methods available:
print("Potato Code: ")
test.expect(str)
test.assert_equals(PotatoCode("hello"), "h tato")
test.assert_equals(PotatoCode("hello world"), "llo wollo wohello w tato")
test.assert_equals(PotatoCode("hello world!"), "llo worllo worhello wo tato")
test.assert_equals(PotatoCode("potato code test program."),"tato code test progrtato code test progrpotato code test prog tato")
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings
Your goal is to have a function where the input gets you a correct output according to the pattern.
For example:
- the input 5 should output 576
- the input 6 should output
Good luck!
SCROLL DOWN FOR HINTS
.
.
.
.
.
.
.
.
.
.
.
.
HINT #1:
-There is 1 multiplication symbol, and one pair of parenthesis (atleast, depending on the way you make the function)
HINT #2:
- The program can run in 1 line of code.
HINT #3:
- The input 15 gives an output of 1936
def pattern(n):
output = n[:]
return (output*2 + 14)**2
'''
READ:
- input 5 should output 576
- input 6 should output
'''
test.expect(int)
test.assert_equals(5, 576, "INCORRECT OUTPUT")
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings