{"id":2475,"date":"2022-08-02T14:43:21","date_gmt":"2022-08-02T06:43:21","guid":{"rendered":"http:\/\/cnliutz.uicp.io\/?p=2475"},"modified":"2022-08-02T14:43:21","modified_gmt":"2022-08-02T06:43:21","slug":"python%e5%be%aa%e7%8e%afwhilefor","status":"publish","type":"post","link":"http:\/\/i10bu9ku.ipyingshe.net:5347\/?p=2475","title":{"rendered":"python\u5faa\u73afwhile&#038;for"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code># -*- coding: utf-8 -*-\n\"\"\"\nSpyder Editor\n\nThis is a temporary script file.\n\"\"\"\ndef ln():\n    print(\"-\"*80)\nln()\nprint(list(range(3,11,2)))\n\n#while using method\nsuma=0\nj=1\nwhile j&lt;101:\n     suma +=j\n     j +=1\n \nprint(j,suma)\nln()\nprint(sum(range(1,101)))\nln()\n#for using method\nfor i in range(3,11,2):\n    print(i,end=\"\")\nprint(\"\\n\")   \ns = \"Python\"   \nfor c in s:\n    print(c,end =\"\")\nprint(\"\\n\")\nfor i in range(len(s)):\n    print(s&#91;i],end =\"\")\nprint(\"\\n\")\nln()\nx = iter(range(1,11,3))\nfor i in x:\n    print(i)\nln()\nprint(type(x))\nln()\n#which one can not repeat 5 times\na = 0\nwhile a &lt; 5:\n    a += 1\n    print(a,end=\"\")\nprint()   \nfor a in range(5):\n    print(a,end=\"\")\nprint()    \nfor a in range(1, 5, 1):\n    print(a,end=\"\")\nprint()\niters = &#91;1, 2, 3, 4, 5]\nfor a in iters:\n    print(a,end=\"\")\nprint(\"\\n\")\n\ni,j,k = 0,0,0\ncount=0\ns =&#91;]\nfor i in range(21):\n    for j in range(51):\n        t=100-5*i-2*j\n        if t>0:\n               s.append(t)\n               count +=1\nprint(\"Money compound count=\",s)\nprint(len(s))\nprint(count)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-2475","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"http:\/\/i10bu9ku.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/2475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/i10bu9ku.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/i10bu9ku.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/i10bu9ku.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/i10bu9ku.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2475"}],"version-history":[{"count":0,"href":"http:\/\/i10bu9ku.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/2475\/revisions"}],"wp:attachment":[{"href":"http:\/\/i10bu9ku.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/i10bu9ku.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2475"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/i10bu9ku.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}