Jump to content

en English cardinal, python Z13588
en Implementation

ཡོང་ཁུངས་Wikifunctions
improving
strip leading "and
ཐིག་ཕྲེང་༡༡: ཐིག་ཕྲེང་༡༡:
"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 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 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 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 = [(\"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 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()"
}
}
},
},

༠༣:༡༥, ༦ ཟླ་བ་གསུམ་པ། ༢༠༢༤ ལ་བཅོས་པ།

This page displays in a limited way without JavaScript.
"https://www.wikifunctions.org/w/index.php?title=Z13588&oldid=85465"ལས་སླར་རྙེད་སོང།