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 18:30
What is outfitting a workplace with video in a technology
Answers: 2
question
Computers and Technology, 22.06.2019 21:00
Describir textbook icon_person mira los dibujos y describe lo que está pasando. usa los verbos de la lista.
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Why is an outfitting a workspace with video games in a technology development company considered a strategic use of money
Answers: 1
question
Computers and Technology, 23.06.2019 16:00
Does read theory have answers keys ?
Answers: 1
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
Computers and Technology, 07.06.2020 08:57
question
Mathematics, 07.06.2020 08:57
question
Mathematics, 07.06.2020 08:57
question
Mathematics, 07.06.2020 08:57
question
Biology, 07.06.2020 08:57
Questions on the website: 13722360