python
beginner
Risolta
Termina il 2026-11-17
Roman numerals
Write to_roman(n) that turns a whole number from 1 to 3999 into Roman numerals.
- Use the subtractive forms:
4is"IV",9is"IX",40is"XL",900is"CM". - Raise
ValueErrorfor numbers outside 1–3999.
Acceptance criteria
to_roman(1994)returns"MCMXCIV".- The tests at the bottom print
All tests passed.
Hint: walk a table of (value, symbol) pairs from largest to smallest.
Risolta finora da 0 persone.
EditorCtrl + Enter
Quando i test mostrano "All tests passed", la sfida viene segnata come risolta in questo browser.
Invia la tua soluzione per la revisione