{ "type": "code_options", "author": "csdn.net", "source": "solution.md", "exercise_id": "53be93ad31624900a621d8a1980e3d15", "keywords": "猜大小", "title": "python 编程 猜数字", "desc": [ { "content": "\n

游戏(猜数字):随机生成一个数字(取值范围[1,100])。让用户猜数字,并给出相应的提示:\n如果用户输入比答案大,提示‘Too big, try again’;\n反之,提示‘Too small, try again’;\n如果猜中了,提示‘Congratulations!’。\n最后,要给出反馈(答案,猜的次数,猜的历史)。\n

", "language": "markdown" } ], "answer": [ { "content": "", "language": "python" } ], "prepared": [ [ { "content": "", "language": "python" } ], [ { "content": "", "language": "python" } ], [ { "content": "", "language": "python" } ] ], "template": { "content": "import random\nv=random.randint(1,100)\ncount=0\nhis=[]\nwhile 1:\n\tvi=input(\"输入猜测值:\")\n\tcount+=1\n\this.append(vi)\n\tif int(vi)>v:\n\t\tprint(\"Too big,try again\")\n\tif int(vi)