solution.json 1.7 KB
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
{
  "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<p>要求编写函数fn(a,n) 求a&#43;aa&#43;aaa&#43;&#43;⋯&#43;aa⋯aa(n个a&#xff09;之和&#xff0c;fn须返回的是数列和。\n从控制台输入正整数a和n的值&#xff08;两个值都不超过9&#xff09;&#xff0c;并输出fn(a,n)的结果值。</p>",
      "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"
}