{ "type": "code_options", "author": "csdn.net", "source": "solution.md", "exercise_id": "d6b1bd5d6de4490288108c61d739ee4f", "keywords": "算法初阶,基础知识,函数的增长,标准记号与常用函数", "title": "要求编写函数fn(a,n) 求a+aa+aaa++⋯+aa⋯aa(n个a)之和,fn须返回的是数列和", "desc": [ { "content": "\n
要求编写函数fn(a,n) 求a+aa+aaa++⋯+aa⋯aa(n个a)之和,fn须返回的是数列和。\n从控制台输入正整数a和n的值(两个值都不超过9),并输出fn(a,n)的结果值。
", "language": "markdown" } ], "answer": [ { "content": "", "language": "python" } ], "prepared": [ [ { "content": "", "language": "python" } ], [ { "content": "", "language": "python" } ], [ { "content": "", "language": "python" } ] ], "template": { "content": "def fun(a,n):\n\ts = 1\n\tsum = 1\n\tfor i in range(1,n):\n\t\ts = 1 + s*10\n\t\tsum+=s\n\ty = a *sum\n\tprint(y)\ndef main():\n\twhile(1):\n\t\ta = int(input('请输入a:'))\n\t\tif a>9 or a<0: \n\t\t\tprint('a的值输入错误,请重新输入:')\n\t\telse:\n\t\t\tbreak\n\twhile(1):\n\t\tn = int(input('请输入n:'))\n\t\tif n>9 or n<0: \n\t\t\tprint('n的值输入错误,请重新输入:')\n\t\telse:\n\t\t\tbreak\n\tfun(a,n)\nif __name__ == '__main__':\n\tmain()", "language": "python" }, "node_id": "dailycode-95f5fc9c54d0497ab2c97dd8c49b8629", "license": "csdn.net", "created_at": 1637894161, "topic_link": "https://bbs.csdn.net/topics/600469890" }