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, 23.06.2019 00:30
Quic which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
question
Computers and Technology, 23.06.2019 05:20
What did creator markus “notch" persson initially call his game
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
How do you write an argumentative essay about the importance of free enterprise ?
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
The first screen you see when you open word2016 what is called?
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
Mathematics, 06.10.2020 22:01
question
Social Studies, 06.10.2020 22:01
question
Mathematics, 06.10.2020 22:01
question
History, 06.10.2020 22:01