Question: Python def math_help(text): # Fill in your code here for Part 2 return None # Change or replace this line if __name__ == __main__ :

Python

Python def math_help(text): # Fill in your code here for Part 2

def math_help(text): # Fill in your code here for Part 2  return None # Change or replace this line  
if __name__ == "__main__": 
 print('Testing math_help() for \"3+2+1+1\": \"' + str(math_help('3+2+1+1')) + '\"') print('Testing math_help() for \"1+2+3\": \"' + str(math_help('1+2+3')) + '\"') print('Testing math_help() for \"2+2+2\": \"' + str(math_help('2+2+2')) + '\"') print('Testing math_help() for \"1+3+2+3+2+1+3+2+3+1+2\": \"' + str(math_help('1+3+2+3+2+1+3+2+3+1+2')) + '\"') 

Susie is learning arithmetic, but she's not so good at it yet. When the teacher writes down the sum of several numbers together, like 1 +3+2+ 1, Susie has to rearrange the numbers into ascending order before adding them. For example, she would rearrange the previous example to 1 +1+2+ 3 before doing the math. Complete the function math-help (problem) that takes a string representing a math problem and rearranges the digits so that Susie can compute the sum. The function will return the rearranged sum as a string. You may assume that only digits 1, 2 and 3 appear in the argument string problem. You may also assume that at least one symbol appears in problem and that problem is always formatted properly Examples: Function Call Return Value T 1+1+2+37 math help 3+2+1+1') (71+2+37) 21 2132 math help 22 2+2' math help ('2+2') math-help 1+3+2+3+2+1+3+2+3+1+2') '1+1+1+2+2+2+2+3+3+3+3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!