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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:00, hannahliebl2000
What is the largest decimal number that can be represented by a binary number with 4 place values? (remember, each place in a binary number has a value of a power of 2, starting in the ones place with 20.)
Answers: 3
image
Computers and Technology, 22.06.2019 10:40, Morghurley2000
"it security policy enforcement and monitoring" respond to the following: describe how monitoring worker activities can increase the security within organizations. describe the rationale that managers should use to determine the degree of monitoring that the organization should conduct. explain the extent to which you believe an organization has the right to monitor user actions and traffic. determine the actions organizations can take to mitigate the potential issues associated with monitoring user actions and traffic.
Answers: 3
image
Computers and Technology, 23.06.2019 07:50, madim1275
Most shops require the technician to enter a starting and ending time on the repair order to track the actual time the vehicle was in the shop and closed out by the office. this time is referred to as _ time ? a. comeback b. ro c. cycle d. lead
Answers: 1
image
Computers and Technology, 24.06.2019 03:30, ava1018
The footer area of a web page generally houses which website feature? terms of use web page content business name or title menu headings
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 in other subjects:

Konu
Mathematics, 19.05.2020 14:02
Konu
Mathematics, 19.05.2020 14:02
Konu
Mathematics, 19.05.2020 14:02