Unit Converter CLI
Build a command-line tool that converts between units of length, weight, and temperature, reading conversion requests from arguments or an interactive prompt. Learners practice argument parsing, functions, dictionaries for lookup tables, and basic error handling for invalid input.
- Estimate
- ~7.5h
- Steps
- 5
- Completed by
- 0
- Proposed by
- codeseed.app
argparse
Project roadmap
- 01
Set up the project and argument parser
~1hCreate a Python script and use argparse to accept a value, source unit, and target unit as command-line arguments.
- 02
Implement conversion functions
~2hWrite functions for length, weight, and temperature conversions using dictionaries to map unit pairs to formulas.
- 03
Add input validation and error messages
~1.5hHandle unsupported units and non-numeric values gracefully with clear error messages instead of crashes.
- 04
Add an interactive mode
~1.5hLet the tool prompt the user for values in a loop when run without arguments, so it works both interactively and via flags.
- 05
Write tests and polish output formatting
~1.5hAdd unit tests for each conversion type and format results with sensible rounding and unit labels.
Resources
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack