P47PythonBeginnerDesign10 min

Define a Function Contract for a Revenue Parsing Helper

Design input, output, and edge-case behavior for a messy revenue parsing helper.

#design#functions#parsing

Scenario

Revenue values arrive as '$1,250.00', ' 850 ', '', and 'unknown'. Analysts need numeric values without silently inventing revenue.

Problem statement

Define a clear function contract before implementing it.

Your Task

  1. Specify accepted inputs and output type.
  2. Choose behavior for blanks and invalid text.
  3. State how callers can distinguish invalid from zero.

Related Concepts

Function contractsMissing valuesParsing

Ready to count this problem?

Mark it complete when you have reasoned through the solution in your own words.