import\x20random\n\nsecret\x20=\x20random.randint(1,\x2010)\nguess\x20=\x200\ntries\x20=\x200\n\nprint("请你猜一猜从1到10,会是什么数字?")\nprint("你只有3次机会哦!")\n\nwhile\x20tries\x20<\x203:\n\tguess\x20=\x20int(input("请输入你猜的数字:"))\n\tties\x20+=\x201\n\t\nif\x20guess\x20<\x20secret:\n\t print("太小了!!!!!!!!!!")\n\telif\x20guess\x20>\x20secret:\n\t print("太大了!!!!!!!!!!")\n\telse:\n\t print("恭喜你,猜对了!")\n\t break\n\nif\x20guess\x20!=\x20secret:\n\tprint("很可惜,你猜错了!")\n\tprint("正确的数字为:"\x20+\x20str(secret))

Python 猜数字游戏:3次机会猜中1到10之间的随机数

原文地址: https://www.cveoy.top/t/topic/pSpL 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录