Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python def math_help(text): # Fill in your code here for Part 2 return None # Change or replace this line if __name__ == __main__ :
Python
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started