Converting cm or m to ft and inches is always difficult.
Online one gets decimal ft, which then need to be converted to inches
I want a simple python script to take a length in meter and covert it in ft and inches
1.76m -> 5 ft 12
Converting cm or m to ft and inches is always difficult.
Online one gets decimal ft, which then need to be converted to inches
I want a simple python script to take a length in meter and covert it in ft and inches
1.76m -> 5 ft 12
Intake — refined spec (no code yet, per route rules).
Repo is empty; this is greenfield, so the spec below is driven entirely by the issue body. One number to flag before anything is built:
The worked example is off. 1.76 m × 39.3700787 in/m = 69.29 in total = 5 ft 9.29 in, not "5 ft 12". And "5 ft 12 in" isn't a legal imperial length — 12 in rolls up to 1 ft, so it would actually be 6 ft 0 in. So the target output format matters a lot. Here's the refined spec with the pieces I need you to pick on.
What it should do (proposed)
Input: a length in metres (single number, e.g. 1.76).
Output: feet + inches, e.g. 5 ft 9 in.
Pure standard library, no deps. A few lines.
Open questions (please pick)
Inch precision — which of these is the intended output?
(a) whole inches, rounded: 1.76 m → 5 ft 9 in
(b) nearest 1/8" (tape-measure style): 1.76 m → 5 ft 9¼ in (9.25")
(c) decimal inches: 1.76 m → 5 ft 9.29 in
(d) exact fraction /12: 1.76 m → 5 ft 111/120 in
For hardware (cutting wood/metal) (b) is usually what people actually use.
Rounding rule — round to nearest, or always round down (truncation)? (Truncation undershoots the real length.)
Input form — just metres, or also accept cm? Title says "cm or m to ft and inches". One unit (m) or both?
Interface — command-line arg (python conv.py 1.76), interactive prompt, or importable function? And CLI only, or also a reusable function?
Output units — feet + inches only, or also show the raw decimal-feet value (5.77 ft) alongside?
Negative / zero — reject, or handle?
Default I'd suggest (not adopted — your call)
Whole-inch rounding (a), metres input only for v1, CLI arg + importable m_to_ft_in(x) returning (feet, inches), decimal-feet string alongside. Say GO: + the options you want and I'll build it.
**Intake — refined spec (no code yet, per route rules).**
Repo is empty; this is greenfield, so the spec below is driven entirely by the issue body. One number to flag before anything is built:
**The worked example is off.** 1.76 m × 39.3700787 in/m = **69.29 in total = 5 ft 9.29 in**, not "5 ft 12". And "5 ft 12 in" isn't a legal imperial length — 12 in rolls up to 1 ft, so it would actually be 6 ft 0 in. So the target output format matters a lot. Here's the refined spec with the pieces I need you to pick on.
### What it should do (proposed)
- Input: a length in metres (single number, e.g. `1.76`).
- Output: feet + inches, e.g. `5 ft 9 in`.
- Pure standard library, no deps. A few lines.
### Open questions (please pick)
1. **Inch precision** — which of these is the intended output?
- (a) whole inches, rounded: `1.76 m → 5 ft 9 in`
- (b) nearest 1/8" (tape-measure style): `1.76 m → 5 ft 9¼ in` (9.25")
- (c) decimal inches: `1.76 m → 5 ft 9.29 in`
- (d) exact fraction /12: `1.76 m → 5 ft 111/120 in`
For hardware (cutting wood/metal) (b) is usually what people actually use.
2. **Rounding rule** — round to nearest, or always round down (truncation)? (Truncation undershoots the real length.)
3. **Input form** — just metres, or also accept cm? Title says "cm or m to ft and inches". One unit (m) or both?
4. **Interface** — command-line arg (`python conv.py 1.76`), interactive prompt, or importable function? And CLI only, or also a reusable function?
5. **Output units** — feet + inches only, or also show the raw decimal-feet value (`5.77 ft`) alongside?
6. **Negative / zero** — reject, or handle?
### Default I'd suggest (not adopted — your call)
Whole-inch rounding (a), metres input only for v1, CLI arg + importable `m_to_ft_in(x)` returning `(feet, inches)`, decimal-feet string alongside. Say `GO:` + the options you want and I'll build it.
1. (a) rounded inches
2. round to the nearest.
3. just meter for this mvp
4. command line is fine to start.
5. ft and inches only.
6. reject negative
Review the above.
Review of your picks — all good, one nit, no blockers.
(a) whole inches, round to nearest — confirmed consistent. Verified: 1.76 m = 69.29 in → 5 ft 9 in. (So the issue's "5 ft 12" example was just a typo — the algorithm carries correctly: 1.5129 m = 59.56 in → 60 in → 5 ft 0 in, never "5 ft 12 in".) Nit: Python's built-in round() is round-half-even (banker's), not round-half-up. A total of exactly N.5 in would round to the even number. It can't realistically bite here (it'd require a decimal-metre input that lands exactly on a .5-inch half), but I'll implement round-half-up anyway — one extra line, removes the question.
Round to nearest — fine for a height/dimension tool; no issue.
Metres only — agreed for MVP. Adding --cm later is a 3-line change if you ever want it.
CLI — fine. I'll make it python3 convert.py 1.76 with the number also accepted with a trailing m (1.76m), and a clear error + exit code 1 on bad input (non-numeric, missing arg).
ft + in only — fine.
Reject negative — fine. Zero stays legal: 0 → 0 ft 0 in (nothing to reject, just a short object).
Final spec (locked, no open questions):
Input: one command-line arg, a non-negative number of metres.
Output: exactly N ft M in, e.g. 5 ft 9 in; round-half-up on the total inches; foot carry automatic.
No more questions on my side. Say GO: when you want it built.
**Review of your picks — all good, one nit, no blockers.**
1. **(a) whole inches, round to nearest** — confirmed consistent. Verified: 1.76 m = 69.29 in → **5 ft 9 in**. (So the issue's "5 ft 12" example was just a typo — the algorithm carries correctly: 1.5129 m = 59.56 in → 60 in → 5 ft 0 in, never "5 ft 12 in".)
*Nit:* Python's built-in `round()` is round-**half-even** (banker's), not round-half-up. A total of exactly N.5 in would round to the even number. It can't realistically bite here (it'd require a decimal-metre input that lands exactly on a .5-inch half), but I'll implement round-half-up anyway — one extra line, removes the question.
2. **Round to nearest** — fine for a height/dimension tool; no issue.
3. **Metres only** — agreed for MVP. Adding `--cm` later is a 3-line change if you ever want it.
4. **CLI** — fine. I'll make it `python3 convert.py 1.76` with the number also accepted with a trailing `m` (`1.76m`), and a clear error + exit code 1 on bad input (non-numeric, missing arg).
5. **ft + in only** — fine.
6. **Reject negative** — fine. Zero stays legal: `0 → 0 ft 0 in` (nothing to reject, just a short object).
**Final spec (locked, no open questions):**
- Input: one command-line arg, a non-negative number of metres.
- Output: exactly `N ft M in`, e.g. `5 ft 9 in`; round-half-up on the total inches; foot carry automatic.
- Stdlib only, single file, no dependencies.
- Errors (negative, non-numeric, missing arg) → message to stderr, exit 1.
No more questions on my side. Say `GO:` when you want it built.
Done — built to the locked spec (GO received, comment #106).
convert.py is on main (832 bytes, single file, stdlib only, no deps).
$ python3 convert.py 1.76
5 ft 9 in
Input: one CLI arg, non-negative metres (1.76 or 1.76m).
Output: exactly N ft M in, whole inches, round-half-up (not banker's), foot carry automatic.
Errors (negative / non-numeric / missing arg) → stderr, exit 1. 0 → 0 ft 0 in stays legal.
Verified against the spec, incl. the round-half-up edge: 0.0635 m = 2.5 in → 0 ft 3 in (banker's rounding would give 2). 1.524 m = 60 in exactly → 5 ft 0 in. All pass.
Left deliberately out (add when you want): cm input, decimal/fractional inches, importable-module packaging — each is a small add, say the word.
**Done — built to the locked spec (GO received, comment #106).**
`convert.py` is on `main` (832 bytes, single file, stdlib only, no deps).
```
$ python3 convert.py 1.76
5 ft 9 in
```
- Input: one CLI arg, non-negative metres (`1.76` or `1.76m`).
- Output: exactly `N ft M in`, whole inches, round-**half-up** (not banker's), foot carry automatic.
- Errors (negative / non-numeric / missing arg) → stderr, exit 1. `0 → 0 ft 0 in` stays legal.
Verified against the spec, incl. the round-half-up edge: `0.0635 m` = 2.5 in → `0 ft 3 in` (banker's rounding would give 2). `1.524 m` = 60 in exactly → `5 ft 0 in`. All pass.
Left deliberately out (add when you want): cm input, decimal/fractional inches, importable-module packaging — each is a small add, say the word.
This repo is archived. You cannot comment on issues.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Converting cm or m to ft and inches is always difficult.
Online one gets decimal ft, which then need to be converted to inches
I want a simple python script to take a length in meter and covert it in ft and inches
1.76m -> 5 ft 12
Intake — refined spec (no code yet, per route rules).
Repo is empty; this is greenfield, so the spec below is driven entirely by the issue body. One number to flag before anything is built:
The worked example is off. 1.76 m × 39.3700787 in/m = 69.29 in total = 5 ft 9.29 in, not "5 ft 12". And "5 ft 12 in" isn't a legal imperial length — 12 in rolls up to 1 ft, so it would actually be 6 ft 0 in. So the target output format matters a lot. Here's the refined spec with the pieces I need you to pick on.
What it should do (proposed)
1.76).5 ft 9 in.Open questions (please pick)
1.76 m → 5 ft 9 in1.76 m → 5 ft 9¼ in(9.25")1.76 m → 5 ft 9.29 in1.76 m → 5 ft 111/120 inFor hardware (cutting wood/metal) (b) is usually what people actually use.
python conv.py 1.76), interactive prompt, or importable function? And CLI only, or also a reusable function?5.77 ft) alongside?Default I'd suggest (not adopted — your call)
Whole-inch rounding (a), metres input only for v1, CLI arg + importable
m_to_ft_in(x)returning(feet, inches), decimal-feet string alongside. SayGO:+ the options you want and I'll build it.Review the above.
Review of your picks — all good, one nit, no blockers.
Nit: Python's built-in
round()is round-half-even (banker's), not round-half-up. A total of exactly N.5 in would round to the even number. It can't realistically bite here (it'd require a decimal-metre input that lands exactly on a .5-inch half), but I'll implement round-half-up anyway — one extra line, removes the question.--cmlater is a 3-line change if you ever want it.python3 convert.py 1.76with the number also accepted with a trailingm(1.76m), and a clear error + exit code 1 on bad input (non-numeric, missing arg).0 → 0 ft 0 in(nothing to reject, just a short object).Final spec (locked, no open questions):
N ft M in, e.g.5 ft 9 in; round-half-up on the total inches; foot carry automatic.No more questions on my side. Say
GO:when you want it built.GO:
Done — built to the locked spec (GO received, comment #106).
convert.pyis onmain(832 bytes, single file, stdlib only, no deps).1.76or1.76m).N ft M in, whole inches, round-half-up (not banker's), foot carry automatic.0 → 0 ft 0 instays legal.Verified against the spec, incl. the round-half-up edge:
0.0635 m= 2.5 in →0 ft 3 in(banker's rounding would give 2).1.524 m= 60 in exactly →5 ft 0 in. All pass.Left deliberately out (add when you want): cm input, decimal/fractional inches, importable-module packaging — each is a small add, say the word.