{"id":753,"date":"2018-08-17T16:30:27","date_gmt":"2018-08-17T07:30:27","guid":{"rendered":"https:\/\/python-introduction.com\/?p=753"},"modified":"2018-08-17T16:30:27","modified_gmt":"2018-08-17T07:30:27","slug":"%e3%80%90python%e3%80%91%e8%a4%87%e6%95%b0%e3%81%aeif%e6%96%87%e3%82%92%e5%85%a5%e3%82%8c%e3%81%9f%e8%a4%87%e9%9b%91%e3%81%aa%e6%9d%a1%e4%bb%b6%e5%88%86%e5%b2%90%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/python-introduction.com\/?p=753","title":{"rendered":"\u3010Python\u3011\u8907\u6570\u306eif\u6587\u3092\u5165\u308c\u305f\u8907\u96d1\u306a\u6761\u4ef6\u5206\u5c90\u306b\u3064\u3044\u3066\u89e3\u8aac"},"content":{"rendered":"<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u524d\u56de\u89e3\u8aac\u3057\u305fif\u6587\u306e\u767a\u5c55\u7de8\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<br \/>\nif\u6587\u306e\u4e2d\u306bif\u6587\u3092\u5165\u308c\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<p>\u8907\u6570\u306eif\u6587\u3092\u6271\u3063\u3066\u3044\u304f\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3001<br \/>\n\u3082\u3057if\u6587\u306e\u57fa\u790e\u304b\u3089\u5b66\u3093\u3067\u307f\u305f\u3044\u65b9\u306f<br \/>\n\u3053\u3061\u3089\u306e\u8a18\u4e8b\u3092\u5148\u306b\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<div class=\"linkcard\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"4\"><tbody><\/tr><tr><td>\u3053\u306e\u8a18\u4e8b\u3067\u306fif\u6587\u3067elif\u3068else\u3092\u3069\u3046\u3084\u3063\u3066\u4f7f\u3044\u5206\u3051\u305f\u3089\u3088\u3044\u304b\u89e3\u8aac\u3057\u307e\u3059\u3002elif\u3068else\u3092\u4f7f\u3044\u5206\u3051\u308b\u65b9\u6cd5\u3092\u7406\u89e3\u3059\u308b\u305f\u3081\u306b\u307e\u305a\u7c21\u5358\u3067\u306f\u3042\u308a\u307e\u3059\u304c\u6761\u4ef6\u5206\u5c90\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002\u3010Python\u5165\u9580\u3011\u6761\u4ef6\u5206\u5c90\u3068\u306f\uff1fif\u6587\u3092\u7406\u89e3\u3059\u308b\u5927\u524d\u63d0\u6761\u4ef6\u5206\u5c90\u3068\u306f\u300c\u3082\u3057A\u304cB\u306a\u3089\u3070C\u3092\u5b9f\u884c\u3057...<br><a class=\"no_icon\" href=\"https:\/\/python-introduction.com\/?p=729\">\u3010Python\u5165\u9580\u3011if\u6587\u3067elif\u3068else\u3092\u4f7f\u3044\u5206\u3051\u308b\u8003\u3048\u65b9<\/a> - python\u5165\u9580\u30c9\u30c3\u30c8\u30b3\u30e0<\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u307e\u305a\u3001if\u6587\u3092\u6271\u3046\u3068\u304d\u306b\u91cd\u8981\u306a\u30a4\u30f3\u30c7\u30f3\u30c8\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#Pythonif\"><span class=\"toc_number toc_depth_1\">1<\/span> \u3010Python\u3011if\u6587\u3068\u30a4\u30f3\u30c7\u30f3\u30c8\u306e\u95a2\u4fc2<\/a><\/li><li><a href=\"#Pythonifif\"><span class=\"toc_number toc_depth_1\">2<\/span> \u3010Python\u3011if\u6587\u306e\u4e2d\u306bif\u6587\u304c\u8907\u6570\u5165\u308b\u8907\u96d1\u306a\u30bf\u30a4\u30d7<\/a><\/li><li><a href=\"#Pythonif-2\"><span class=\"toc_number toc_depth_1\">3<\/span> \u3010Python\u5165\u9580\u3011if\u6587\u306e\u5fdc\u7528\u30d1\u30bf\u30fc\u30f3<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Pythonif\">\u3010Python\u3011if\u6587\u3068\u30a4\u30f3\u30c7\u30f3\u30c8\u306e\u95a2\u4fc2<\/span><\/h2>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/pcccroujin816.jpg\" alt=\"\u30a4\u30f3\u30c7\u30f3\u30c8\" width=\"620\" height=\"414\" class=\"alignnone size-full wp-image-720\" srcset=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/pcccroujin816.jpg 620w, https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/pcccroujin816-300x200.jpg 300w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<p>\u307e\u305a\u305d\u3082\u305d\u3082\u30a4\u30f3\u30c7\u30f3\u30c8\u3068\u306f\u5b57\u4e0b\u3052\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u984c1\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">#\u4f8b\u984c1\r\na = 3\r\nb = 'Python'\r\n\r\nif a &lt; 4:\r\n    b = '\u30d1\u30a4\u30bd\u30f3'\r\n    print(b)<\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068<\/p>\n<p>\u300e\u30d1\u30a4\u30bd\u30f3\u300f\u3068\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3067\u3001\u30a4\u30f3\u30c7\u30f3\u30c8\u306f\u4e0b\u8a18\u753b\u50cf\u306e\u8d64\u67a0\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/indennnn816.jpg\" alt=\"\u30a4\u30f3\u30c7\u30f3\u30c8\" width=\"229\" height=\"165\" class=\"alignnone size-full wp-image-757\" \/><\/p>\n<p>Python\u4ee5\u5916\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u306f<br \/>\n\u30a4\u30f3\u30c7\u30f3\u30c8\u306f\u305f\u3044\u3066\u3044\u898b\u305f\u76ee\u306e\u554f\u984c\u3067\u3059\u3002<\/p>\n<p>\u30a4\u30f3\u30c7\u30f3\u30c8\u304c\u3042\u3063\u305f\u65b9\u304c\u898b\u3084\u3059\u3044\u304b\u3089\u3064\u3051\u3066\u3044\u308b\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>Python\u4ee5\u5916\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u306f<br \/>\n\u30a4\u30f3\u30c7\u30f3\u30c8\u3063\u3066\u305d\u3053\u307e\u3067\u6df1\u3044\u610f\u5473\u3092\u6301\u3061\u307e\u305b\u3093\u3002<\/p>\n<p>\u3067\u3082\u3001Python\u306e\u5834\u5408\u3001\u30a4\u30f3\u30c7\u30f3\u30c8\u306b\u306f\u610f\u5473\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\nPython\u306b\u304a\u3051\u308b\u30a4\u30f3\u30c7\u30f3\u30c8\u306f\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u4e00\u90e8\u3068\u3057\u3066\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u30a4\u30f3\u30c7\u30f3\u30c8\u306b\u306a\u3063\u3066\u3044\u306a\u3044\u305f\u3081\u306b<br \/>\nPython\u3060\u3068\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3057\u307e\u3046\u3053\u3068\u304c\u3042\u308b\u3093\u3067\u3059\u3002<\/p>\n<p>\u7279\u306b\u3001if\u6587\u4e2d\u306e\u30a4\u30f3\u30c7\u30f3\u30c8\u306f\u91cd\u8981\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u984c2\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<br \/>\n\u30a4\u30f3\u30c7\u30f3\u30c8\u3092\u306a\u304f\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">#\u4f8b\u984c2\r\na = 3\r\nb = 'Python'\r\n\r\nif a &lt; 4:\r\nb = '\u30d1\u30a4\u30bd\u30f3'\r\nprint(b)<\/pre>\n<p>\u4f8b\u984c2\u3092\u5b9f\u884c\u3059\u308b\u3068\u30a8\u30e9\u30fc\u304c\u3067\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/inndnentoh816.jpg\" alt=\"\u30a4\u30f3\u30c7\u30f3\u30c8\" width=\"420\" height=\"230\" class=\"alignnone size-full wp-image-758\" srcset=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/inndnentoh816.jpg 420w, https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/inndnentoh816-300x164.jpg 300w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/p>\n<p>\u306a\u305c\u4f8b\u984c2\u306f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u306e\u3067\u3057\u3087\u3046\uff1f<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">if a &lt; 4:\r\nb = '\u30d1\u30a4\u30bd\u30f3'<\/pre>\n<p>\u306e<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">b = '\u30d1\u30a4\u30bd\u30f3'<\/pre>\n<p>\u3067\u3001if\u6587\u306e\u9014\u4e2d\u306a\u306e\u306b\u30a4\u30f3\u30c7\u30f3\u30c8\u304c\u306a\u3044\u3068<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">b = '\u30d1\u30a4\u30bd\u30f3'<\/pre>\n<p>\u306fif\u6587\u306b\u95a2\u4fc2\u306e\u306a\u3044\u3082\u306e\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>if\u6587\u306e\u6761\u4ef6\u306b\u5408\u81f4\u3057\u305f\u5834\u5408\u306e\u7d50\u679c\u304c<br \/>\n\u306a\u3044\u304b\u3089\u30a8\u30e9\u30fc\u306b\u306a\u3063\u305f\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>\u9006\u306b<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">#\u4f8b\u984c1\r\na = 3\r\nb = 'Python'\r\n\r\nif a &lt; 4:\r\n    b = '\u30d1\u30a4\u30bd\u30f3'\r\n    print(b)<\/pre>\n<p>\u3068\u30a4\u30f3\u30c7\u30f3\u30c8\u304c\u3042\u308b\u3068\u3001<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">    b = '\u30d1\u30a4\u30bd\u30f3'<\/pre>\n<p>\u306f\u3001if\u6587\u306b\u5408\u81f4\u3057\u305f\u7d50\u679c<br \/>\n\u5909\u6570b\u306b\u300e\u30d1\u30a4\u30bd\u30f3\u300f\u3092\u4ee3\u5165\u3059\u308b\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u3093\u3068\u306a\u304f\u308f\u304b\u3063\u3066\u3044\u305f\u3060\u3051\u305f\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067Python\u306e\u5834\u5408\u3001<br \/>\nif\u6587\u306e\u4e2d\u306f\u3057\u3063\u304b\u308a\u3068\u30a4\u30f3\u30c7\u30f3\u30c8\u3092\u3042\u3051\u306a\u3044\u3068<br \/>\n\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u3054\u6ce8\u610f\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2><span id=\"Pythonifif\">\u3010Python\u3011if\u6587\u306e\u4e2d\u306bif\u6587\u304c\u8907\u6570\u5165\u308b\u8907\u96d1\u306a\u30bf\u30a4\u30d7<\/span><\/h2>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/pcsoto816.jpg\" alt=\"\u8907\u6570\u306eif\u6587\" width=\"620\" height=\"470\" class=\"alignnone size-full wp-image-760\" srcset=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/pcsoto816.jpg 620w, https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/pcsoto816-300x227.jpg 300w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<p>if\u6587\u306e\u4e2d\u306bif\u6587\u3092\u5165\u308c\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<br \/>\n\u4f8b\u984c3\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">#\u4f8b\u984c3\r\na = 30\r\nb = 0\r\nc = 5\r\n\r\nif a &lt; 20:\r\n    if c == 10:\r\n        b += 23\r\n    else:\r\n        b += 10\r\nelse:\r\n    if c == 10:\r\n        b += 300\r\n    else:\r\n        b += 9997\r\n        \r\nb += 2\r\nprint(b)<\/pre>\n<p>\u307e\u305a\u4f8b\u984c3\u3067\u306f<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">a = 30\r\nb = 0\r\nc = 5<\/pre>\n<p>\u5909\u6570a\u306b30\u3001<br \/>\n\u5909\u6570b\u306b0<br \/>\n\u5909\u6570c\u306b5\u3092<br \/>\n\u305d\u308c\u305e\u308c\u4ee3\u5165\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u304b\u3089<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">if a &lt; 20:\r\n    if c == 10:\r\n        b += 23\r\n    else:\r\n        b += 10<\/pre>\n<p>\u3053\u3053\u3067if\u6587\u304c\u767b\u5834\u3057\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u5909\u6570a\u304c20\u3088\u308a\u5c0f\u3055\u3044\u5024\u306a\u3089\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u306d\u3002<br \/>\n\u3057\u304b\u3082if\u6587\u306e\u4e2d\u306b\u3055\u3089\u306bif\u6587\u304c\u3042\u3063\u3066<br \/>\n\u5909\u6570c\u304c10\u306a\u3089\u5909\u6570b\u306b23\u3092\u52a0\u3048\u307e\u3059\u3002<\/p>\n<p>\u5909\u6570a\u304c20\u3088\u308a\u5c0f\u3055\u3044\u5024\u3060\u3051\u3069<br \/>\n\u5909\u6570c\u304c10\u3067\u306a\u3044\u306a\u3089\u3001\u5909\u6570b\u306b10\u3092\u52a0\u3048\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u4f8b\u984c3\u3067\u306f\u5909\u6570a\u304c30\u306a\u306e\u3067<br \/>\n\u4e0a\u8a18\u3069\u308c\u3082\u5f53\u3066\u306f\u307e\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3060\u304b\u3089\u3055\u3089\u306b\u4e0b\u306e\u65b9\u306b\u9032\u3093\u3067\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3053\u3053\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">else:\r\n    if c == 10:\r\n        b += 300\r\n    else:\r\n        b += 9997<\/pre>\n<p>\u4e0a\u8a18\u306f\u5909\u6570a\u304c10\u3088\u308a\u5c0f\u3055\u304f\u306a\u3044\u5834\u5408\u3001<br \/>\n\u8a00\u3044\u65b9\u3092\u304b\u3048\u308b\u306810\u4ee5\u4e0a\u306e\u5834\u5408\u306e\u51e6\u7406\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u3001\u5909\u6570a\u306f30\u306a\u306e\u3067\u3053\u3053\u304c\u5f53\u3066\u306f\u307e\u308a\u307e\u3059\u3002<br \/>\n\u3067\u3001c\u304c10\u306a\u3089\u5909\u6570b\u306b300\u3092\u52a0\u3048\u307e\u3059\u3002<\/p>\n<p>\u3067\u3082\u3001\u5909\u6570c\u306f5\u306a\u306e\u3067\u5f53\u3066\u306f\u307e\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u3053\u3067b\u306b9997\u3092\u52a0\u3048\u307e\u3059\u3002<\/p>\n<p>\u3057\u305f\u304c\u3063\u3066\u3001<span class=\"yellowbg\">\u3053\u306e\u6642\u70b9\u3067\u5909\u6570b\u306f<br \/>\n0\uff0b9997\uff1d9999<br \/>\n\u3068\u306a\u3063\u3066\u3044\u307e\u3059<\/span>\u3002<\/p>\n<p>\u3055\u3089\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u3069\u3093\u3069\u3093\u4e0b\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">b += 2\r\nprint(b)<\/pre>\n<p>\u5909\u6570b\u306f9997\u3067\u3059\u304c\u3001<br \/>\n\u3053\u3053\u3067\u306f\u5358\u7d14\u306b\u6761\u4ef6\u306b\u95a2\u4fc2\u306a\u304f2\u3092\u52a0\u3048\u307e\u3059\u3002<\/p>\n<p><span class=\"yellowbg\">\u3060\u304b\u3089\u5909\u6570b\u306f9997\uff0b2\uff1d9999\u3068\u306a\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>\u3057\u305f\u304c\u3063\u3066print(b)\u304c\u3042\u308b\u306e\u3067<br \/>\n9999\u3068\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/ifunonakanoifu816.jpg\" alt=\"if\u6587\u306e\u4e2d\u306eif\" width=\"246\" height=\"356\" class=\"alignnone size-full wp-image-762\" srcset=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/ifunonakanoifu816.jpg 246w, https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/ifunonakanoifu816-207x300.jpg 207w\" sizes=\"(max-width: 246px) 100vw, 246px\" \/><\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067if\u6587\u306e\u4e2d\u306b\u8907\u6570\u306eif\u6587\u3092\u5165\u308c\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2><span id=\"Pythonif-2\">\u3010Python\u5165\u9580\u3011if\u6587\u306e\u5fdc\u7528\u30d1\u30bf\u30fc\u30f3<\/span><\/h2>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/pccccsi86.jpg\" alt=\"\u8907\u96d1\u306aif\u6587\" width=\"620\" height=\"477\" class=\"alignnone size-full wp-image-764\" srcset=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/pccccsi86.jpg 620w, https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/pccccsi86-300x231.jpg 300w\" sizes=\"(max-width: 620px) 100vw, 620px\" \/><\/p>\n<p>\u6700\u5f8c\u306b\u3053\u3053\u307e\u3067\u52c9\u5f37\u3057\u3066\u304d\u305fif\u6587\u3092\u4f7f\u3063\u3066<br \/>\n\u4f8b\u984c\u3092\u4e00\u7dd2\u306b\u307f\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">#\u4f8b\u984c4\r\na = 21\r\nb = 0\r\n\r\nif a &lt; 10:\r\n    b += 100\r\nelif a &lt; 20:\r\n    b += 123\r\nelse:\r\n    b += 10000\r\n    \r\nb += 1\r\nprint(b)<\/pre>\n<p>\u4f8b\u984c4\u3092\u5b9f\u884c\u3059\u308b\u3068<br \/>\n\u300e10001\u300f\u3068\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u984c4\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u306d\u3002<\/p>\n<p>\u307e\u305a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">a = 21\r\nb = 0<\/pre>\n<p>\u3053\u3053\u3067\u3001\u5909\u6570a\u306b21\u3092\u4ee3\u5165\u3057<br \/>\n\u5909\u6570b\u306b0\u3092\u4ee3\u5165\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">if a &lt; 10:\r\n    b += 100\r\nelif a &lt; 20:\r\n    b += 123\r\nelse:\r\n    b += 10000<\/pre>\n<p>\u3067\u3059\u304c\u3001\u3082\u3057\u5909\u6570a\u304c10\u3088\u308a\u5c0f\u3055\u3044\u306a\u3089<br \/>\n\u5909\u6570b\u306b10\u52a0\u3048\u307e\u3059\u3002<\/p>\n<p>\u3067\u3082\u3001\u5909\u6570a\u306f21\u306a\u306e\u3067\u3001\u305d\u306e\u307e\u307e\u4e0b\u306e<br \/>\nelif\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>elif\u3067\u306f\u5909\u6570a\u304c20\u3088\u308a\u5c0f\u3055\u3044\u306a\u3089<br \/>\n\u5909\u6570b\u306b123\u3092\u52a0\u3048\u307e\u3059\u3002<\/p>\n<p>\u304c\u3001\u5909\u6570a\u306f21\u306a\u306e\u3067\u3001<br \/>\n\u3053\u3053\u3067\u3082\u8a72\u5f53\u3057\u307e\u305b\u3093\u3002<\/p>\n<p>\u306a\u306e\u3067\u305d\u306e\u307e\u307e\u4e0b\u306eelse\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<br \/>\nelse\u306b\u5909\u6570a\u306e21\u306f\u8a72\u5f53\u3057\u307e\u3059\u3002<br \/>\nelse\u307e\u3067\u306e\u3044\u305a\u308c\u306b\u3082\u8a72\u5f53\u3057\u306a\u304b\u3063\u305f\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067else\u306e\u3068\u3053\u308d\u3067<br \/>\n\u5909\u6570b\u306b10000\u304c\u52a0\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u5909\u6570b\u306f0+10000\uff1d10000\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u6700\u5f8c\u306b<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">b += 1\r\nprint(b)<\/pre>\n<p>\u3067\u3059\u306d\u3002<\/p>\n<p>\u3053\u3053\u3067\u5927\u4e8b\u306a\u306e\u306f\u30a4\u30f3\u30c7\u30f3\u30c8\u304c\u306a\u3044\u3068\u3053\u308d\u3067\u3059\u306d\u3002<br \/>\n\u30a4\u30f3\u30c7\u30f3\u30c8\u304c\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u306fPython\u3067\u306f<br \/>\nif\u6587\u306e\u4e2d\u306b\u300eb += 1\u300f\u304c\u8a72\u5f53\u3057\u306a\u3044\u3053\u3068\u3092\u610f\u5473\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u5358\u7d14\u306b\u73fe\u6642\u70b9\u3067\u306e\u5909\u6570b\u306e\u6570\u5024\u300110000\u306b<br \/>\n\u3055\u3089\u306b1\u3092\u52a0\u3048\u307e\u3059\u3002<\/p>\n<p>\u3057\u305f\u304c\u3063\u3066\u5909\u6570b\u306f<br \/>\n10000+1=10001<br \/>\n\u3068\u306a\u308a\u3001\u5b9f\u884c\u3059\u308b\u3068<br \/>\n10001\u304c\u8868\u793a\u3055\u308c\u308b\u308f\u3051\u3067\u3059\u306d\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/ififiifi816.jpg\" alt=\"if\u6587\" width=\"420\" height=\"230\" class=\"alignnone size-full wp-image-766\" srcset=\"https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/ififiifi816.jpg 420w, https:\/\/python-introduction.com\/wp-content\/uploads\/2018\/08\/ififiifi816-300x164.jpg 300w\" sizes=\"(max-width: 420px) 100vw, 420px\" \/><\/p>\n<p>\u4eca\u56de\u3082\u524d\u56de\u306b\u5f15\u304d\u7d9a\u304d\u3001if\u6587\u306b\u3064\u3044\u3066\u52c9\u5f37\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u524d\u56de\u306e\u8a18\u4e8b\u306f\u3053\u3061\u3089\u3067\u3059\u3002<br \/>\n<div class=\"linkcard\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"4\"><tbody><\/tr><tr><td>\u3053\u306e\u8a18\u4e8b\u3067\u306fif\u6587\u3067elif\u3068else\u3092\u3069\u3046\u3084\u3063\u3066\u4f7f\u3044\u5206\u3051\u305f\u3089\u3088\u3044\u304b\u89e3\u8aac\u3057\u307e\u3059\u3002elif\u3068else\u3092\u4f7f\u3044\u5206\u3051\u308b\u65b9\u6cd5\u3092\u7406\u89e3\u3059\u308b\u305f\u3081\u306b\u307e\u305a\u7c21\u5358\u3067\u306f\u3042\u308a\u307e\u3059\u304c\u6761\u4ef6\u5206\u5c90\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002\u3010Python\u5165\u9580\u3011\u6761\u4ef6\u5206\u5c90\u3068\u306f\uff1fif\u6587\u3092\u7406\u89e3\u3059\u308b\u5927\u524d\u63d0\u6761\u4ef6\u5206\u5c90\u3068\u306f\u300c\u3082\u3057A\u304cB\u306a\u3089\u3070C\u3092\u5b9f\u884c\u3057...<br><a class=\"no_icon\" href=\"https:\/\/python-introduction.com\/?p=729\">\u3010Python\u5165\u9580\u3011if\u6587\u3067elif\u3068else\u3092\u4f7f\u3044\u5206\u3051\u308b\u8003\u3048\u65b9<\/a> - python\u5165\u9580\u30c9\u30c3\u30c8\u30b3\u30e0<\/td><\/tr><\/tbody><\/table><\/div><\/p>\n<p>if\u6587\u304c\u95a2\u4fc2\u3059\u308b\u6761\u4ef6\u5206\u5c90\u306f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u91cd\u8981\u30dd\u30a4\u30f3\u30c8\u306b\u306a\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002<br \/>\n\u306a\u306e\u3067\u3001\u3053\u306e\u8a18\u4e8b\u3068\u524d\u56de\u306e\u8a18\u4e8b\u3092\u4f55\u56de\u3082\u898b\u8fd4\u3057\u3066<br \/>\n\u5fa9\u7fd2\u3057\u3066\u3044\u305f\u3060\u3051\u308b\u3068\u3046\u308c\u3057\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u524d\u56de\u89e3\u8aac\u3057\u305fif\u6587\u306e\u767a\u5c55\u7de8\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002 if\u6587\u306e\u4e2d\u306bif\u6587\u3092\u5165\u308c\u305f\u308a\u3057\u307e\u3059\u3002 \u8907\u6570\u306eif\u6587\u3092\u6271\u3063\u3066\u3044\u304f\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3001 \u3082\u3057if\u6587\u306e\u57fa\u790e\u304b\u3089\u5b66\u3093\u3067\u307f\u305f\u3044\u65b9\u306f \u3053\u3061\u3089\u306e\u8a18\u4e8b\u3092\u5148\u306b\u3054\u89a7\u304f\u3060\u3055\u3044\u3002 \u307e\u305a\u3001i [&hellip;]","protected":false},"author":1,"featured_media":754,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[53,16],"tags":[54,3,57],"_links":{"self":[{"href":"https:\/\/python-introduction.com\/index.php?rest_route=\/wp\/v2\/posts\/753"}],"collection":[{"href":"https:\/\/python-introduction.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/python-introduction.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/python-introduction.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/python-introduction.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=753"}],"version-history":[{"count":7,"href":"https:\/\/python-introduction.com\/index.php?rest_route=\/wp\/v2\/posts\/753\/revisions"}],"predecessor-version":[{"id":767,"href":"https:\/\/python-introduction.com\/index.php?rest_route=\/wp\/v2\/posts\/753\/revisions\/767"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/python-introduction.com\/index.php?rest_route=\/wp\/v2\/media\/754"}],"wp:attachment":[{"href":"https:\/\/python-introduction.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/python-introduction.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/python-introduction.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}