python
beginner
已解决
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.
目前已有 0 人解出。
编辑器Ctrl + Enter
当测试输出 "All tests passed" 时,此挑战会在本浏览器中标记为已解决。
提交您的解决方案进行审核