Your question is Print a Simple Python Result. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A small utility in Reply's machine-learning tooling must display the result of one basic calculation consistently. Implement a function that evaluates two numbers with a supplied operator and returns a formatted string suitable for printing.
Implement format_calculation(a, b, operator), where a and b are numbers, and operator is one of +, -, *, or /. Return a string in the exact format a operator b = result. For division, assume b is nonzero. Use Python's normal arithmetic rules, including decimal division with /. The input will always contain a supported operator.
Do not print inside the function. Returning the string keeps the function easy to test, and a caller can print the returned value directly.
a and b are integers or floating-point numbersoperator is one of +, -, *, /b is nonzero when the operator is /def format_calculation(a, b, operator):