{ "type": "code_options", "author": "csdn.net", "source": "solution.md", "exercise_id": "3da60a14561e42a0abd5e52778d30ec3", "keywords": "图算法,算法高阶,图的表示,基本的图算法", "title": "随机生成车牌号", "desc": [ { "content": "\n
某市随机生成车辆号牌的规则是:号牌字头为\"某A-\",\"某B-\"等(字母为除了C以外的A~H范围内的大写字母),字头后面由5位字符组成,第1位必须是数字;第2、3、4、5位可以是任意数字或不含字母\"O\"的大写英文字母。\n程序功能为:调用自己设计的函数license_plate(),随机生成5个车辆号牌,等待输入一个心仪号码的序号选择号牌,并将其打印输出。\n程序运行结果如下图所示:\n
", "language": "markdown" } ], "answer": [ { "content": "", "language": "python" } ], "prepared": [ [ { "content": "", "language": "python" } ], [ { "content": "", "language": "python" } ], [ { "content": "", "language": "python" } ] ], "template": { "content": "import random\ndef genrndchar(metachar):\n\treturn metachar[int(random.random() * len(metachar))]\ndef license_plate():\n\ts = \"某\"\n\ts = s + genrndchar(['A', 'B', 'C', 'D', 'E', 'H'])\n\ts = s + '-'\n\ts = s + genrndchar(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'])\n\tfor i in range(4):\n\t\ts = s + genrndchar(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'])\n\treturn s\nlst = []\nfor i in range(5):\n\tplate = license_plate()\n\tlst.append(plate)\n\tprint(str(i + 1) + \":\" + plate)\nx = int(input(\"请输入您心仪的号牌序号:\")) - 1\nprint(\"您选中的号牌为:\" + lst[x])", "language": "python" }, "node_id": "dailycode-5e0a54189fd843a8954fa9ae5aac50a0", "license": "csdn.net", "created_at": 1637894161, "topic_link": "https://bbs.csdn.net/topics/600470298" }