{"id":135,"date":"2025-08-17T23:19:56","date_gmt":"2025-08-17T23:19:56","guid":{"rendered":"https:\/\/learn.rantissi.my.id\/?p=135"},"modified":"2025-08-17T23:19:58","modified_gmt":"2025-08-17T23:19:58","slug":"pengenalan-modul-library-bawaan-python","status":"publish","type":"post","link":"https:\/\/learn.rantissi.my.id\/index.php\/2025\/08\/17\/pengenalan-modul-library-bawaan-python\/","title":{"rendered":"Pengenalan Modul &amp; Library Bawaan Python"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"apa-itu-modul\">Apa itu Modul?<\/h2>\n\n\n\n<p>Modul = file berisi kode Python siap pakai (fungsi, kelas, dll)<\/p>\n\n\n\n<p>Gunakan dengan:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import nama_modul\n<\/code><\/pre>\n\n\n\n<p>Atau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from nama_modul import fungsi_tertentu\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1-modul-math\">1. Modul&nbsp;<code>math<\/code><\/h2>\n\n\n\n<p>Modul matematika<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import math\n\nprint(math.sqrt(25))       # akar kuadrat\nprint(math.pow(2, 3))      # pangkat\nprint(math.ceil(4.2))      # pembulatan ke atas\nprint(math.floor(4.9))     # pembulatan ke bawah\nprint(math.pi)             # konstanta \u03c0\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-modul-random\">2. Modul&nbsp;<code>random<\/code><\/h2>\n\n\n\n<p>Untuk membuat data acak<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import random\n\nprint(random.randint(1, 10))         # angka acak 1\u201310\nprint(random.choice(&#91;\"a\", \"b\", \"c\"]))  # acak dari list\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-modul-datetime\">3. Modul&nbsp;<code>datetime<\/code><\/h2>\n\n\n\n<p>Untuk tanggal dan waktu<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import datetime\n\nsekarang = datetime.datetime.now()\nprint(\"Hari ini:\", sekarang)\n\nprint(\"Tahun:\", sekarang.year)\nprint(\"Bulan:\", sekarang.month)\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4-modul-time\">4. Modul&nbsp;<code>time<\/code><\/h2>\n\n\n\n<p>Untuk delay\/sleep, timer, dll<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import time\n\nprint(\"Mulai...\")\ntime.sleep(2)   # jeda 2 detik\nprint(\"Selesai setelah 2 detik\")<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Apa itu Modul? Modul = file berisi kode Python siap pakai (fungsi, kelas, dll) Gunakan dengan: Atau: 1. Modul&nbsp;math Modul matematika 2. Modul&nbsp;random Untuk membuat data acak 3. Modul&nbsp;datetime Untuk tanggal dan waktu 4. Modul&nbsp;time Untuk delay\/sleep, timer, dll<\/p>\n","protected":false},"author":1,"featured_media":20,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7],"tags":[],"class_list":["post-135","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","category-python"],"_links":{"self":[{"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/posts\/135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/comments?post=135"}],"version-history":[{"count":2,"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/posts\/135\/revisions"}],"predecessor-version":[{"id":137,"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/posts\/135\/revisions\/137"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/media\/20"}],"wp:attachment":[{"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/media?parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/categories?post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn.rantissi.my.id\/index.php\/wp-json\/wp\/v2\/tags?post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}