{"id":3151,"date":"2021-02-14T21:20:52","date_gmt":"2021-02-14T12:20:52","guid":{"rendered":"https:\/\/www.python.ambitious-engineer.com\/?p=3151"},"modified":"2021-02-14T21:22:58","modified_gmt":"2021-02-14T12:22:58","slug":"%e9%96%a2%e6%95%b0%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%88%e3%81%86","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/3151","title":{"rendered":"\u95a2\u6570\u3092\u4f5c\u3063\u3066\u307f\u3088\u3046"},"content":{"rendered":"<p>\u524d\u56de\u3001\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002\u95a2\u6570\u306f\u7d44\u307f\u8fbc\u307f\u306e\u3082\u306e\u4ee5\u5916\u306b\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u81ea\u8eab\u3067\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h2>\u72ec\u81ea\u306b\u95a2\u6570\u3092\u4f5c\u308b\u65b9\u6cd5<\/h2>\n<p>\u521d\u6b69\u7684\u306a\u95a2\u6570\u306f\u4ee5\u4e0b\u306e\u69cb\u6587\u3067\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u300c\u95a2\u6570\u306e\u51e6\u7406\u306f\u3053\u3046\u3057\u307e\u3059\u3088\u300d\u3068\u3044\u3046\u51e6\u7406\u3092\u8a18\u8ff0\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u3046\u3044\u3063\u305f\u8a18\u8ff0\u3092<strong>\u95a2\u6570\u306e\u5b9a\u7fa9<\/strong>\u3068\u3082\u547c\u3073\u307e\u3059\u3002\u5b9f\u969b\u3001def\u306f\u82f1\u8a9e\u306edefine\uff08\u5b9a\u7fa9\u3059\u308b\uff09\u306e\u7565\u304b\u3089\u304d\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef \u95a2\u6570\u540d(\u5f15\u65701, \u5f15\u65702, \u30fb\u30fb\u30fb):\r\n    \u51e6\u7406\r\n    return \u623b\u308a\u5024\r\n<\/pre>\n<p>\u95a2\u6570\u3092\u4f5c\u308b\u969b\u306fdef\u3067\u5ba3\u8a00\u3092\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u95a2\u6570\u540d\u306b\u7d9a\u304f\u62ec\u5f27\u3067\u5f15\u6570\u3068\u547c\u3070\u308c\u308b\u5909\u6570\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u3082\u3063\u3068\u3082\u3001\u3053\u308c\u3060\u3051\u3060\u3068\u4f55\u306e\u3053\u3068\u304b\u308f\u304b\u3089\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u5177\u4f53\u7684\u306a\u4f8b\u3092\u307f\u3066\u5b66\u7fd2\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u3001\u6bd4\u8f03\u7684\u7c21\u5358\u306a\u95a2\u6570\u3001\u300c\u5f15\u6570\u3067\u6307\u5b9a\u3057\u305f2\u3064\u306e\u6570\u5b57\u3092\u8db3\u3059\u300d\u51e6\u7406\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef add2numbers(x, y):\r\n    z = x + y\r\n    return z\r\n<\/pre>\n<p>\u95a2\u6570\u540d\u3068\u3057\u3066add2numbers\u3068\u3044\u3046\u540d\u524d\u3092\u4ed8\u3051\u307e\u3057\u305f\u30022\u6570\u306e\u5f15\u6570\u306fx, y\u3068\u3044\u3046\u540d\u524d\u3092\u4ed8\u3051\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u3001x + y \u3092\u8a08\u7b97\u3057\u3066z\u306b\u683c\u7d0d\u3057\u623b\u308a\u5024\u3068\u3057\u3066\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305b\u3063\u304b\u304f\u95a2\u6570\u3092\u4f5c\u3063\u305f\u306e\u3067\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u547c\u3073\u51fa\u3057\u65b9\u306f\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u306e\u3068\u304d\u3068\u540c\u69d8\u3067\u3059\u3002\u4ee5\u4e0b\u306f\u4f5c\u3063\u305f\u95a2\u6570add2numbers\u3092\u4f7f\u7528\u3057\u30662\u30683\u306e\u548c\u3092\u6c42\u3081\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef add2numbers(x, y):\r\n    z = x + y\r\n    return z\r\n\r\nans = add2numbers(2, 3)\r\nprint(ans)    # \u548c\u306e5\u304c\u8868\u793a\u3055\u308c\u308b\r\n<\/pre>\n<p>\u3055\u3066\u30012\u6570\u3092\u8db3\u3059\u3060\u3051\u3060\u3068\u4eca\u307e\u3067\u3069\u304a\u308a\u95a2\u6570\u3092\u4f7f\u308f\u306a\u3044\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3082\u3044\u3044\u3058\u3083\u306a\u3044\u304b\u3001\u3068\u601d\u3046\u65b9\u3082\u3044\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\uff1f<br \/>\n\u5b9f\u969b\u3001\u7c21\u5358\u306a\u51e6\u7406\u30921\u56de\u5b9f\u884c\u3059\u308b\u306a\u3089\u3070\u95a2\u6570\u3092\u4f7f\u308f\u306a\u304f\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001<strong>\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u3068\u8907\u96d1\u306a\u51e6\u7406\u304c1\u56de\u66f8\u3044\u305f\u3060\u3051\u3067\u4f55\u56de\u3082\u4f7f\u3044\u307e\u308f\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059<\/strong>\u3002<\/p>\n<p>\u4e0a\u306e\u95a2\u6570\u3067\u306f\u548c\u3092\u623b\u308a\u5024\u3068\u3057\u3066\u8fd4\u3057\u307e\u3057\u305f\u304c\u3001\u623b\u308a\u5024\u306e\u306a\u3044\u95a2\u6570\u3082\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u300c\u5f15\u6570\u3067\u53d7\u3051\u53d6\u3063\u305f2\u6570\u306e\u548c\u3092print\u51fa\u529b\u3059\u308b\u95a2\u6570\u300d\u3067\u3059\u3002<strong>\u623b\u308a\u5024\u306f\u5fc5\u305a\u3057\u3082\u5fc5\u8981\u3068\u3044\u3046\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093<\/strong>\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef add2numbers(x, y):\r\n    z = x + y\r\n    print(z)\r\n\r\nadd2numbers(2, 3)    # \u548c\u306e5\u304c\u8868\u793a\u3055\u308c\u308b\r\n<\/pre>\n<p>Python\u306f\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3068\u6bd4\u8f03\u3057\u3066\u95a2\u6570\u306e\u6a5f\u80fd\u304c\u5f37\u529b\u3067\u3001\u69d8\u3005\u306a\u66f8\u304d\u65b9\u304c\u5b58\u5728\u3057\u307e\u3059\u3002\u8208\u5473\u304c\u3042\u308b\u65b9\u306f\u662f\u975e\u5165\u9580\u7de8\u3078\u52c9\u5f37\u3092\u9032\u3081\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>\u6f14\u7fd2<\/h2>\n<h3>\u6f14\u7fd2\u554f\u984c1<\/h3>\n<p>3\u3064\u306e\u6570\u3092\u8db3\u3059\u95a2\u6570\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u307e\u305f\u3001\u4f5c\u6210\u3057\u305f\u95a2\u6570\u3092\u4efb\u610f\u306e\u5f15\u6570\u30673\u56de\u547c\u3073\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><b>\u89e3\u7b54\u4f8b<\/b><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef add3numbers(x, y, z):\r\n    w = x + y + z\r\n    return w\r\n\r\n# 1\u56de\u547c\u3073\u51fa\u3057\r\nans1 = add3numbers(1, 3, 5)\r\nprint(ans1)    # 9\r\n\r\n# 2\u56de\u547c\u3073\u51fa\u3057\r\nans2 = add3numbers(2, 4, 6)\r\nprint(ans2)    # 12\r\n\r\n# 3\u56de\u547c\u3073\u51fa\u3057\r\nans3 = add3numbers(3, 5, 7)\r\nprint(ans3)    # 15\r\n<\/pre>\n<h3>\u6f14\u7fd2\u554f\u984c2<\/h3>\n<p>\u5f15\u6570\u3067\u6307\u5b9a\u3057\u305f\u6570\u5024\u306e\u30ea\u30b9\u30c8\u3092\u8db3\u3057\u4e0a\u3052\u308b\u95a2\u6570\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u307e\u305f\u3001\u4f5c\u6210\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u547c\u3073\u51fa\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><b>\u89e3\u7b54\u4f8b<\/b><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef mysum(numberlist):\r\n    sum_val = 0\r\n    for x in numberlist:\r\n        sum_val = sum_val + x\r\n    return sum_val\r\n\r\nl = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\r\nans = mysum(l)\r\nprint(ans)     # 55\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u3001\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002\u95a2\u6570\u306f\u7d44\u307f\u8fbc\u307f\u306e\u3082\u306e\u4ee5\u5916\u306b\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u81ea\u8eab\u3067\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002 \u72ec\u81ea\u306b\u95a2\u6570\u3092\u4f5c\u308b\u65b9\u6cd5 \u521d\u6b69\u7684\u306a\u95a2\u6570\u306f\u4ee5\u4e0b\u306e\u69cb\u6587\u3067\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u300c\u95a2\u6570\u306e\u51e6\u7406\u306f\u3053\u3046\u3057\u307e\u3059\u3088\u300d\u3068\u3044\u3046\u51e6\u7406\u3092\u8a18...<\/p>\n","protected":false},"author":1,"featured_media":3154,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[206],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/3151"}],"collection":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/comments?post=3151"}],"version-history":[{"count":5,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/3151\/revisions"}],"predecessor-version":[{"id":3261,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/3151\/revisions\/3261"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media\/3154"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=3151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=3151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=3151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}