subject

Complete the following function, strcat_ba(a, b), so that given two strings, a and b, it returns the concatenation of b followed by a (pay attention to the order in these instructions!). In [18]: def strcat_ba(a, b): assert type(a) is str, f"Input argument "a" has "type(a) is {type(a) } rather than str' " return (a+b) assert type(b) is str, f"Input argument b' has "type(b) is {type(b) } rather than 'str' " In [8]: # strcat_ba_test : Test cell # Workaround: # Python 3.5.2 does not have random. choices() (available in 3.6+) def random_letter( ) : from random import choice return choice( '' ) def random_string(n, fun=random_letter) : return '' . join( [str (fun() ) for _ in range(n) ]) = random_string(5) b = random_string(3) c = strcat_ba(a, b) print( 'streat_ba("{}", "{}") == "{}" . format(a, b, c)) assert len(c) == len(a) + len(b), " c' has the wrong length: {len(c)} rather than {len(a)+len(b)}" assert c[ : len(b) ] == b assert c [-len(a) : ] == a print ("\n(Passed!)") streat_ba( "fazcw", "cpe") == "fazcwcpe" AssertionError Traceback (most recent call last) <ipython-input-8-6618c8ad9c30> ; in <module> 14 print( 'streat_ba("{}", "{}") = = "{}"'. format(a, b, c)) 15 assert len(c) == len(a) + len(b), " c" has the wrong length: {len(c)} rather than {len(a)+len(b)}" ---> 16 assert c[ : len(b) ] == b 17 assert c[- len(a) : ] == a 18 print("\n(Passed! )") AssertionError :

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:30
Complete the sentence based on your knowledge of the professional difficulties faced by music artists. digital technology allows audiences to see free live telecasts of music or dance performances through
Answers: 1
question
Computers and Technology, 22.06.2019 17:30
1. before plugging in a new device to a computer you should unplug all other devices turn off the computer turn on the computer 2. many of the maintenance tools for a computer can be found in the control panel under administrative tools display personalization
Answers: 1
question
Computers and Technology, 22.06.2019 23:00
Suppose s, t, and w are strings that have already been created inside main. write a statement or statements, to be added to main, that will determine if the lengths of the three strings are in order by length, smallest to largest. that is, your code should determine if s is strictly shorter than t, and if t is strictly shorter than w. if these conditions hold your code should print (the boolean value) true. if not, your code should print false. (strictly means: no ties) example: if s, t, and w are "cat", "hats", and "skies" your code should print true - their lengths are 3-4-5; but if s, t, and w are "cats" "shirt", and "trust", then print false - their lengths are 4-5-5 enter your code in the box below
Answers: 2
question
Computers and Technology, 24.06.2019 00:00
Visualizing a game of β€œtag” to remember the meaning of contagious
Answers: 3
You know the right answer?
Complete the following function, strcat_ba(a, b), so that given two strings, a and b, it returns the...
Questions
question
English, 28.12.2019 08:31
question
Mathematics, 28.12.2019 08:31
question
Mathematics, 28.12.2019 08:31
Questions on the website: 13722363