{"id":416,"date":"2019-01-05T00:40:30","date_gmt":"2019-01-04T15:40:30","guid":{"rendered":"https:\/\/www.nblog09.com\/w\/?p=416"},"modified":"2021-06-12T15:16:36","modified_gmt":"2021-06-12T06:16:36","slug":"python-function","status":"publish","type":"post","link":"https:\/\/www.nblog09.com\/w\/2019\/01\/05\/python-function\/","title":{"rendered":"Python\u306e\u95a2\u6570\u306e\u4f7f\u3044\u65b9\u3001\u5f15\u6570\u306e\u6307\u5b9a\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570\u3092\u5229\u7528\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<h2 class=\"title-border\"><strong>\u95a2\u6570\u306e\u57fa\u672c<\/strong><\/h2>\n<p>python\u3067\u306f\u95a2\u6570\u306f<\/p>\n<p class=\"pink_span\">def \u95a2\u6570\u540d():<br \/>\n\u00a0 \u00a0\u51e6\u7406<\/p>\n<p>\u3068\u3057\u3066\u5b9a\u7fa9\u3059\u308b\u3002<\/p>\n<p>\u547c\u3073\u51fa\u3059\u5834\u5408\u306b\u306f\u3001<span class=\"pink_span\">\u95a2\u6570\u540d()<\/span>\u3068\u3059\u308b\u3002<\/p>\n<div class=\"programming-gray\">\n<ul>\n<li>\u95a2\u6570\u306e\u5b9a\u7fa9\u3068\u5b9f\u884c<\/li>\n<\/ul>\n<div class=\"programming-inside\">\ndef print_hello(): <strong># \u95a2\u6570\u306e\u5b9a\u7fa9<\/strong><br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;print(\"Hello\") <strong># \u30a4\u30f3\u30c7\u30f3\u30c8\u3057\u3066\u95a2\u6570\u306e\u51e6\u7406\u3092\u8a18\u8ff0 <\/strong><\/p>\n<p>print_hello() <strong># \u95a2\u6570\u306e\u547c\u3073\u51fa\u3057\u3001Hello\u304c\u8868\u793a\u3055\u308c\u308b<\/strong>\n<\/div>\n<\/div>\n<h2 class=\"title-border\"><strong>\u95a2\u6570\u306e\u5f15\u6570\u306e\u6307\u5b9a\u3001\u8fd4\u308a\u5024\u3092\u6307\u5b9a\u3059\u308b\u65b9\u6cd5<\/strong><\/h2>\n<p>python\u306e\u95a2\u6570\u306b\u5f15\u6570\u306b\u4e0e\u3048\u308b\u306b\u306f\u3001<\/p>\n<p class=\"pink_span\">def \u95a2\u6570\u540d(arg1, arg2):<\/p>\n<p>\u306e\u3088\u3046\u306b\u3001\u95a2\u6570\u306e\u5f8c\u306b\u3001\uff08\uff09\u5185\u306b\u3001\u5909\u6570\u540d\u3092\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<p>\u307e\u305f\u3001\u8fd4\u308a\u5024\u3092\u5b9a\u7fa9\u3059\u308b\u306b\u306f\u3001<\/p>\n<p>\u95a2\u6570\u306e\u51e6\u7406\u3092\u7d42\u4e86\u3057\u305f\u3044\u5834\u6240\u306b\u3001<span class=\"pink_span\">return \u5024<\/span>\u3068\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<div class=\"programming-gray\">\n<ul>\n<li>\u95a2\u6570\u306e\u5b9a\u7fa9\u3068\u5b9f\u884c<\/li>\n<\/ul>\n<div class=\"programming-inside\">\ndef num_max<span class=\"codehighlight\">(a, b)<\/span>: <strong># \u5f15\u6570\u3092\u4f7f\u7528\u3057\u305f\u3044\u5834\u5408\u3001()\u5185\u306b\u5909\u6570\u540d\u3092\u8a18\u8ff0\u3059\u308b<\/strong><br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;if a &gt; b:<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return a<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;else:<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return b<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<strong># \u95a2\u6570\u5185\u3067\u306f\u3001\u5927\u304d\u3044\u65b9\u306e\u5f15\u6570\u304c\u8fd4\u3055\u308c\u308b<\/strong><\/p>\n<p>num = num_max(10, 20) <strong># \u5927\u304d\u3044\u65b9\u306e20\u304c\u8fd4\u308b<\/strong><\/p>\n<p># \u8fd4\u308a\u5024\u306f\u3001\u6570\u5024\u3001\u6587\u5b57\u5217\u3060\u3051\u3067\u306a\u304f\u3001\u914d\u5217\u3001\u8f9e\u66f8\u578b\u306a\u3069\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3082\u8fd4\u3059\u3053\u3068\u304c\u3067\u304d\u308b<\/p>\n<p>def get_car(brand, model, year):<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;return {\"brand\": brand, \"model\": model, \"year\": year}<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;<strong># \u8fd4\u308a\u5024\u306b\u8f9e\u66f8\u578b\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b<\/strong><\/p>\n<p>car = get_car(\"Toyota\", \"prius\", 2015) <strong># car\u306b\u306f\u3001\u8f9e\u66f8\u578b\u306e{'brand': 'Toyota', 'model': 'prius', 'year': 2015}\u304c\u683c\u7d0d\u3055\u308c\u308b<\/strong>\n<\/div>\n<\/div>\n<h2 class=\"title-border\"><strong>\u95a2\u6570\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306e\u6307\u5b9a<\/strong><\/h2>\n<p>python\u306e\u95a2\u6570\u3067\u5f15\u6570\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u5024\u306e\u6307\u5b9a\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<p class=\"pink_span\">def function(arg1, arg2=100):<br \/>\n\u00a0   \u51e6\u7406<\/p>\n<p>\u5f15\u6570=\u3007\u3007\u3068\u3059\u308b\u3068\u3001\u547c\u3073\u51fa\u3059\u969b\u306b\u3001\u5024\u3092\u6307\u5b9a\u305b\u305a\u306b\u3082\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<div class=\"programming-gray\">\n<ul>\n<li>\u95a2\u6570\u306e\u5b9a\u7fa9\u3068\u5b9f\u884c<\/li>\n<\/ul>\n<div class=\"programming-inside\">\ndef print_hello(arg1, arg2<span class=\"codehighlight\">=\"World\"<\/span>): <strong># =\u3067\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u6307\u5b9a\u3059\u308b<\/strong><br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;print(\"{} {}\".format(arg1, arg2)) <\/p>\n<p>print(\"Hello\", \"Japan\") <strong># \u5f15\u6570\u30922\u3064\u6307\u5b9a\u3059\u308b\u3068Hello Japan\u3068\u8868\u793a\u3055\u308c\u308b<\/strong><br \/>\nprint(\"Hello\") <strong># \u5f15\u6570\u30921\u3064\u6307\u5b9a\u3059\u308b\u3068arg2\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306eWorld\u3068\u306a\u308a\u3001Hello World\u304c\u8868\u793a\u3055\u308c\u308b<\/strong>\n<\/div>\n<\/div>\n<div class=\"customized-adsense\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u95a2\u6570\u306e\u57fa\u672c python\u3067\u306f\u95a2\u6570\u306f def \u95a2\u6570\u540d(): \u00a0 \u00a0\u51e6\u7406 \u3068\u3057\u3066\u5b9a\u7fa9\u3059\u308b\u3002 \u547c\u3073\u51fa\u3059\u5834\u5408\u306b\u306f\u3001\u95a2\u6570\u540d()\u3068\u3059\u308b\u3002 \u95a2\u6570\u306e\u5b9a\u7fa9\u3068\u5b9f\u884c def print_hello(): # \u95a2\u6570\u306e\u5b9a\u7fa9 &nbsp;&#038;nbsp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":341,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_uag_custom_page_level_css":"","_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[9,219],"tags":[88,14],"class_list":{"0":"post-416","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python","8":"category-it-programming","9":"tag-function","10":"tag-python","11":"entry"},"uagb_featured_image_src":{"full":["https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2018\/12\/note-2527458__480.jpg",720,480,false],"thumbnail":["https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2018\/12\/note-2527458__480-150x150.jpg",150,150,true],"medium":["https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2018\/12\/note-2527458__480-300x200.jpg",300,200,true],"medium_large":["https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2018\/12\/note-2527458__480.jpg",720,480,false],"large":["https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2018\/12\/note-2527458__480.jpg",720,480,false],"1536x1536":["https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2018\/12\/note-2527458__480.jpg",720,480,false],"2048x2048":["https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2018\/12\/note-2527458__480.jpg",720,480,false],"home-middle":["https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2018\/12\/note-2527458__480.jpg",525,350,false],"home-top":["https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2018\/12\/note-2527458__480.jpg",630,420,false],"sidebar-thumbnail":["https:\/\/www.nblog09.com\/w\/wp-content\/uploads\/2018\/12\/note-2527458__480.jpg",100,67,false]},"uagb_author_info":{"display_name":"9nmatsumoto","author_link":"https:\/\/www.nblog09.com\/w\/author\/9nmatsumoto\/"},"uagb_comment_info":1,"uagb_excerpt":"\u95a2\u6570\u306e\u57fa\u672c python\u3067\u306f\u95a2\u6570\u306f def \u95a2\u6570\u540d(): \u00a0 \u00a0\u51e6\u7406 \u3068\u3057\u3066\u5b9a\u7fa9\u3059\u308b\u3002 \u547c\u3073\u51fa\u3059\u5834\u5408\u306b\u306f\u3001\u95a2\u6570&hellip;","_links":{"self":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts\/416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/comments?post=416"}],"version-history":[{"count":18,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts\/416\/revisions"}],"predecessor-version":[{"id":634,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/posts\/416\/revisions\/634"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/media\/341"}],"wp:attachment":[{"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/media?parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/categories?post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nblog09.com\/w\/wp-json\/wp\/v2\/tags?post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}