{"id":1885,"date":"2019-01-15T14:48:30","date_gmt":"2019-01-15T07:48:30","guid":{"rendered":"https:\/\/luckytruedev.com\/learning\/?p=1885"},"modified":"2019-09-21T21:33:31","modified_gmt":"2019-09-21T14:33:31","slug":"contoh-program-percabangan-pada-python","status":"publish","type":"post","link":"https:\/\/luckytruedev.com\/learning\/contoh-program-percabangan-pada-python\/","title":{"rendered":"Contoh Program Percabangan pada Python"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"416\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/python_contoh_ifelse.jpg\" alt=\"\" class=\"wp-image-1891\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/python_contoh_ifelse.jpg 651w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/python_contoh_ifelse-300x192.jpg 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/python_contoh_ifelse-110x70.jpg 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/python_contoh_ifelse-420x268.jpg 420w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/python_contoh_ifelse-20x13.jpg 20w\" sizes=\"auto, (max-width: 651px) 100vw, 651px\" \/><\/figure><\/div>\n\n\n\n<p>Hi, Kali ini gw mau share Cara membuat Percabangan menggunakan bahasa Python, langsung aja gw kasih contoh-contoh dari Percabangan dengan mudah agar kalian dapat mempelajarinya.<\/p>\n\n\n<div id=\"lucky-4288238681\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5605825534849002\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5605825534849002\" \ndata-ad-slot=\"5317815257\" \ndata-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>Program Menentukan Huruf Konsonan dan Vokal<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"344\" height=\"150\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/perbandingan_huruf.png\" alt=\"\" class=\"wp-image-1904\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/perbandingan_huruf.png 344w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/perbandingan_huruf-300x131.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/perbandingan_huruf-110x48.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/perbandingan_huruf-20x9.png 20w\" sizes=\"auto, (max-width: 344px) 100vw, 344px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\"># Program Menentukan Huruf Konsonan dan Vokal\n\nhuruf = input(\"Silahkan Masukan Huruf = \")\nvokal = \"Huruf yang anda masukan adalah huruf vokal\"\nkonsonan = \"huruf yang anda masukan adalah huruf konsonan\"\n\nif(huruf == \"a\", \"A\") :\n    print()\n    print(vokal)\nelif(huruf == \"i\", \"I\") :\n    print()\n    print(vokal)\nelif(huruf == \"u\", \"U\") :\n    print()\n    print(vokal)\nelif(huruf == \"e\", \"E\") :\n    print()\n    print(vokal)\nelif (huruf == \"o\", \"O\") :\n    print()\n    print(vokal)\nelse :\n    print()\n    print(konsonan)<\/pre>\n\n\n<div id=\"lucky-3139575638\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5605825534849002\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5605825534849002\" \ndata-ad-slot=\"3760179245\" \ndata-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>Perbandingan Bilangan<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"361\" height=\"96\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/perbandingan_bilangan.png\" alt=\"\" class=\"wp-image-1905\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/perbandingan_bilangan.png 361w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/perbandingan_bilangan-300x80.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/perbandingan_bilangan-110x29.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/perbandingan_bilangan-20x5.png 20w\" sizes=\"auto, (max-width: 361px) 100vw, 361px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">#Program Perbandingan Bilangan\n\nbil1 = input(\"Masukan Bilangan 1 = \")\nbil2 = input(\"Masukan Bilangan 2 = \")\nif (bil1>bil2) :\n        hasil = \"Besar\"\nelse :\n        hasil = \"Kecil\"\n\nprint()\nprint(\"bilangan\", bil1, \"lebih\", hasil, \"dari pada\", \"bilangan\", bil2)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Program Persyaratan SIM<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"346\" height=\"195\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/menentukan_sim.png\" alt=\"\" class=\"wp-image-1906\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/menentukan_sim.png 346w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/menentukan_sim-300x169.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/menentukan_sim-110x62.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/menentukan_sim-20x11.png 20w\" sizes=\"auto, (max-width: 346px) 100vw, 346px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">#Program Persyaratan SIM\n\numur = int(input(\"Masukan Umur Anda = \"))\nnilai = int(input(\"Masukan Nilai Tes Anda = \"))\nlulus = \"Selamat Anda Berhak Mendapatkan Sim Anda\"\ngagal = \"Maaf, Anda tidak berhak mendapatkan sim anda\\nSilahkan Coba lagi Bulan atau tahun Depan\"\n\nif(umur>17) :\n    if(nilai&lt;60) :\n        print()\n        print(gagal)\n    else :\n        print()\n        print(lulus)\n        \nelse :\n        print()\n        print(gagal)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Program Menentukan Index Nilai<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"295\" height=\"115\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.42.22.png\" alt=\"\" class=\"wp-image-1914\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.42.22.png 295w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.42.22-110x43.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.42.22-20x8.png 20w\" sizes=\"auto, (max-width: 295px) 100vw, 295px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\"># Program Menentukan Index Nilai\n\nnilai = int(input(\"Masukan Nilai = \"))\n\nif (nilai>80) :\n    index = \"A\"\nelif (nilai&lt;=80) and (nilai>65) :\n    index = \"B\"\nelif (nilai&lt;=65) and (nilai>60) :\n    index = \"C\"\nelse :\n    index = \"D\"\nprint(\"anda mendapatkan index =\", index)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Program Tiket Kereta Api<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"321\" height=\"141\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.42.45.png\" alt=\"\" class=\"wp-image-1916\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.42.45.png 321w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.42.45-300x132.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.42.45-110x48.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.42.45-20x9.png 20w\" sizes=\"auto, (max-width: 321px) 100vw, 321px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\"># Program Kereta Api\n\njarak = int(input(\"Masukan Jarak = \"))\nharga_tiket = int(input(\"Masukan Harga Tiket = \"))\n\nif (jarak>300) or (harga_tiket>500000) :\n    beli = harga_tiket*0.5\nelif (jarak>200) or (harga_tiket>300000) :\n    beli = harga_tiket*0.8\nelse :\n    beli = harga_tiket\n    \nprint()\nprint(\"Harga Tiket = Rp\", beli)<\/pre>\n\n\n<div id=\"lucky-3532952485\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5605825534849002\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5605825534849002\" \ndata-ad-slot=\"3760179245\" \ndata-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>Program Mencari Bilangan Terbesar dan Kecil<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"318\" height=\"181\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.43.15.png\" alt=\"\" class=\"wp-image-1917\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.43.15.png 318w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.43.15-300x171.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.43.15-110x63.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.43.15-20x11.png 20w\" sizes=\"auto, (max-width: 318px) 100vw, 318px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\"># Program Mencari Bilangan Terbesar dan Terkecil\n\nbil1 = int(input(\"Masukan Bilangan 1 = \"))\nbil2 = int(input(\"Masukan Bilangan 2 = \"))\nbil3 = int(input(\"Masukan Bilangan 3 = \"))\n\n#Nilai Terbesar\n\nif (bil1>bil2) and (bil1>bil3) :\n    print()\n    print(\"Terbesarnya adalah = \", bil1)\nelif (bil2>bil1) and (bil2>bil3) :\n    print()\n    print(\"Terbesarnya adalah = \", bil2)\nelse :\n    print()\n    print(\"Terbesarnya yaitu = \", bil3)\n\n#Nilai Terkecil\n    \n\nif (bil1&lt;bil2) and (bil1&lt;bil3) :\n    print(\"Terkecilnya adalah = \", bil1)\nelif (bil2&lt;bil1) and (bil2&lt;bil3) :\n    print(\"Terkecilnya adalah = \", bil2)\nelse :\n    print(\"Terkecilnya yaitu = \", bil3)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Program Reg Sms<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"353\" height=\"156\" src=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.43.48.png\" alt=\"\" class=\"wp-image-1918\" srcset=\"https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.43.48.png 353w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.43.48-300x133.png 300w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.43.48-110x49.png 110w, https:\/\/luckytruedev.com\/learning\/wp-content\/uploads\/2019\/01\/Screen-Shot-2019-01-15-at-14.43.48-20x9.png 20w\" sizes=\"auto, (max-width: 353px) 100vw, 353px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\"># Program REG SMS\n\nreg = input(\"Ketik SMS = \")\n\nif (reg[0:4] == \"REG \") :\n    print(\"Selamat anda terdaftar sebagai\", reg[4:len(reg)])\nelse :\n    print(\"Maaf Format anda Salah\")<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Source Code?<\/strong><\/h2>\n\n\n\n<p>Silahkan Kalian Cek pada Situs ini : <br><br>&#8211; <a href=\"https:\/\/github.com\/poncoe\/python_basic\/tree\/master\/bab2_if-else\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/poncoe\/python_basic\/tree\/master\/bab2_if-else<\/a><br>&#8211; <a href=\"https:\/\/github.com\/poncoe\/python_basic\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/poncoe\/python_basic<\/a><\/p>\n<div id=\"lucky-1930592485\" class=\"lucky-after-content lucky-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-5605825534849002\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block;\" data-ad-client=\"ca-pub-5605825534849002\" \ndata-ad-slot=\"5317815257\" \ndata-ad-format=\"auto\" data-full-width-responsive=\"true\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Hi, Kali ini gw mau share Cara membuat Percabangan menggunakan bahasa Python, langsung aja gw kasih contoh-contoh dari Percabangan dengan mudah agar kalian dapat mempelajarinya. Program Menentukan Huruf Konsonan dan Vokal Perbandingan Bilangan Program Persyaratan SIM Program Menentukan Index Nilai Program Tiket Kereta Api Program Mencari Bilangan Terbesar dan Kecil Program Reg Sms Source Code? [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1891,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80],"tags":[],"class_list":["post-1885","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ltdv-python"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts\/1885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/comments?post=1885"}],"version-history":[{"count":2,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts\/1885\/revisions"}],"predecessor-version":[{"id":2264,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/posts\/1885\/revisions\/2264"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/media\/1891"}],"wp:attachment":[{"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/media?parent=1885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/categories?post=1885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/luckytruedev.com\/learning\/wp-json\/wp\/v2\/tags?post=1885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}