Fara í innihald

en English cardinal, python Z13588
en Implementation

Úr Wikifunctions
Ekkert breytingarágrip
NiferO (spjall | framlög)
Translated content to igbo
 
(8 millibreytinga eftir 2 notendur ekki sýndar)
Lína 11: Lína 11:
"Z1K1": "Z16",
"Z1K1": "Z16",
"Z16K1": "Z610",
"Z16K1": "Z610",
"Z16K2": "def Z13587(Z13587K1):\n # define the units and tens place\n ones = [\"\", \"one \", \"two \", \"three \", \"four \", \"five \", \"six \", \"seven \", \"eight \", \"nine \", \"ten \", \"eleven \", \"twelve \", \"thirteen \", \"fourteen \", \"fifteen \", \"sixteen \", \"seventeen \", \"eighteen \", \"nineteen \"]\n tens = [\"\", \"\", \"twenty \", \"thirty \", \"forty \", \"fifty \", \"sixty \", \"seventy \", \"eighty \", \"ninety \"]\n units = [(\"trillion\", 1_000_000_000_000), (\"billion\", 1_000_000_000), (\"million\", 1_000_000), (\"thousand\", 1_000), (\"hundred\", 100), (\"\", 1)]\n\n # function to convert numbers less than 1000 to words\n def words(Z13587K1):\n if Z13587K1 == 0:\n return \"\"\n elif Z13587K1 \u003C= 19:\n return ones[Z13587K1]\n elif Z13587K1 \u003C= 99:\n return tens[Z13587K1 // 10] + ones[Z13587K1 % 10]\n else:\n return ones[Z13587K1 // 100] + \"hundred and \" + words(Z13587K1 % 100)\n\n # convert numbers to words\n if Z13587K1 == 0:\n return \"zero\"\n elif Z13587K1 \u003C 0:\n return \"negative \" + Z13587(-Z13587K1)\n else:\n result = \"\"\n for unit_name, factor in units:\n count, Z13587K1 = divmod(Z13587K1, factor)\n if count \u003E 0:\n if factor == 100:\n result = ones[count] + unit_name + result\n else:\n result = words(count) + unit_name + \" \" + result\n return result.strip()"
"Z16K2": "def Z13587(Z13587K1):\n # define the units and tens place\n ones = [\"\", \"one \", \"two \", \"three \", \"four \", \"five \", \"six \", \"seven \", \"eight \", \"nine \", \"ten \", \"eleven \", \"twelve \", \"thirteen \", \"fourteen \", \"fifteen \", \"sixteen \", \"seventeen \", \"eighteen \", \"nineteen \"]\n tens = [\"\", \"\", \"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\"]\n units = [(\"quattuordecillion\", 1_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000),(\"tredecillion\", 1_000_000_000_000_000_000_000_000_000_000_000_000_000_000),(\"duodecillion\", 1_000_000_000_000_000_000_000_000_000_000_000_000_000),(\"undecillion\", 1_000_000_000_000_000_000_000_000_000_000_000_000),(\"decillion\", 1_000_000_000_000_000_000_000_000_000_000_000),(\"nonillion\", 1_000_000_000_000_000_000_000_000_000_000),(\"octillion\", 1_000_000_000_000_000_000_000_000_000),(\"septillion\", 1_000_000_000_000_000_000_000_000),(\"sextillion\", 1_000_000_000_000_000_000_000),(\"quintillion\", 1_000_000_000_000_000_000), (\"quadrillion\", 1_000_000_000_000_000), (\"trillion\", 1_000_000_000_000), (\"billion\", 1_000_000_000), (\"million\", 1_000_000), (\"thousand\", 1_000), (\"hundred\", 100), (\"\", 1)]\n\n # function to convert numbers less than 1000 to words\n def words(Z13587K1):\n if Z13587K1 == 0:\n return \"\"\n elif Z13587K1 \u003C= 19:\n return ones[Z13587K1]\n elif Z13587K1 \u003C= 99:\n tens_unit = tens[Z13587K1 // 10]\n ones_unit = ones[Z13587K1 % 10]\n return tens_unit + \"-\" + ones_unit if ones_unit else tens_unit\n else:\n return ones[Z13587K1 // 100] + \"hundred and \" + words(Z13587K1 % 100)\n\n # convert numbers to words\n if Z13587K1 == 0:\n return \"zero\"\n elif Z13587K1 \u003C 0:\n return \"negative \" + Z13587(-Z13587K1)\n else:\n result = \"\"\n for unit_name, factor in units:\n count, Z13587K1 = divmod(Z13587K1, factor)\n if count \u003E 999:\n #ERROR: number is too large for this algorithm\n return \"ERROR: number is too large for this algorithm\"\n if count \u003E 0:\n if factor == 100:\n result = result + \" \" + ones[count] + unit_name\n elif factor == 1:\n result = result + \" and \" + words(count) + unit_name\n else:\n result = result + \" \" + words(count) + unit_name\n if (result.startswith(\" and \")): result = result[5:]\n return result.strip()"
}
}
},
},
Lína 22: Lína 22:
"Z11K1": "Z1002",
"Z11K1": "Z1002",
"Z11K2": "English cardinal, python"
"Z11K2": "English cardinal, python"
},
{
"Z1K1": "Z11",
"Z11K1": "Z1014",
"Z11K2": "Kadịnal Bekee, Python"
}
}
]
]
Lína 34: Lína 39:
"Z1K1": "Z12",
"Z1K1": "Z12",
"Z12K1": [
"Z12K1": [
"Z11"
"Z11",
{
"Z1K1": "Z11",
"Z11K1": "Z1002",
"Z11K2": "uses American names for very large numbers."
},
{
"Z1K1": "Z11",
"Z11K1": "Z1014",
"Z11K2": "na-eji aha America maka ọnụọgụ buru ibu."
}
]
]
}
}

Nýjasta útgáfa síðan 27. júní 2024 kl. 00:09

This page displays in a limited way without JavaScript.