{"id":98,"date":"2026-03-02T07:32:25","date_gmt":"2026-03-02T02:32:25","guid":{"rendered":"https:\/\/gigz.pk\/python\/?post_type=lesson&#038;p=98"},"modified":"2026-03-14T10:03:35","modified_gmt":"2026-03-14T05:03:35","slug":"python-standard-library","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/python\/lesson\/python-standard-library\/","title":{"rendered":"\u00a0Python Standard Library"},"content":{"rendered":"\n<p>The Python Standard Library is a collection of built-in modules that come pre-installed with Python.<\/p>\n\n\n\n<p>You do not need to install them using <code>pip<\/code>.<br>They are available immediately after installing Python.<\/p>\n\n\n\n<p>The standard library helps you:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Work with files and folders<\/li>\n\n\n\n<li>Handle dates and time<\/li>\n\n\n\n<li>Perform mathematical operations<\/li>\n\n\n\n<li>Generate random numbers<\/li>\n\n\n\n<li>Work with system and OS features<\/li>\n\n\n\n<li>Process JSON data<\/li>\n\n\n\n<li>And much more<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>WHY USE STANDARD LIBRARY?<\/strong><\/h2>\n\n\n\n<p>\u2022 No installation required<br>\u2022 Reliable and well-tested<br>\u2022 Saves development time<br>\u2022 Covers most common programming tasks<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>COMMONLY USED STANDARD LIBRARY MODULES<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. math<\/strong><\/h3>\n\n\n\n<p>Provides mathematical functions.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import mathprint(math.sqrt(16))<br>print(math.pi)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. random<\/strong><\/h3>\n\n\n\n<p>Generates random numbers.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import randomprint(random.randint(1, 10))<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. datetime<\/strong><\/h3>\n\n\n\n<p>Works with dates and time.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import datetimenow = datetime.datetime.now()<br>print(now)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. os<\/strong><\/h3>\n\n\n\n<p>Interacts with the operating system.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import osprint(os.getcwd())<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. sys<\/strong><\/h3>\n\n\n\n<p>Provides system-specific parameters.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import sysprint(sys.version)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. json<\/strong><\/h3>\n\n\n\n<p>Handles JSON data.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import jsondata = {\"name\": \"Hira\", \"age\": 25}<br>json_data = json.dumps(data)<br>print(json_data)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7. statistics<\/strong><\/h3>\n\n\n\n<p>Performs statistical calculations.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import statisticsnumbers = [10, 20, 30, 40]<br>print(statistics.mean(numbers))<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>8. itertools<\/strong><\/h3>\n\n\n\n<p>Provides tools for working with iterators.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import itertoolsnumbers = [1, 2, 3]<br>for pair in itertools.combinations(numbers, 2):<br>    print(pair)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>HOW TO SEE ALL STANDARD LIBRARY MODULES<\/strong><\/h2>\n\n\n\n<p>You can explore documentation at:<br><a href=\"https:\/\/docs.python.org\/3\/library\/\">https:\/\/docs.python.org\/3\/library\/<\/a><\/p>\n\n\n\n<p>Or inside Python:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">help(\"modules\")<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>STANDARD LIBRARY VS THIRD-PARTY LIBRARIES<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Standard Library<\/th><th>Third-Party Library<\/th><\/tr><\/thead><tbody><tr><td>Comes with Python<\/td><td>Installed using pip<\/td><\/tr><tr><td>No installation needed<\/td><td>Must install manually<\/td><\/tr><tr><td>Official &amp; built-in<\/td><td>Created by developers worldwide<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>BEST PRACTICES<\/strong><\/h2>\n\n\n\n<p>\u2022 Use standard library whenever possible<br>\u2022 Avoid installing external libraries if built-in modules can do the job<br>\u2022 Read official documentation for deeper understanding<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>KEY TAKEAWAY<\/strong><\/h2>\n\n\n\n<p>The Python Standard Library is powerful and comprehensive.<br>It provides ready-to-use tools that allow you to build efficient and professional applications without installing extra packages.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/python\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">PYTHON INTERMEDIATE (PYI) > Modules and Packages > Python Standard Library<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773464684419\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p><\/p>\n","protected":false},"menu_order":45,"template":"","class_list":["post-98","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u00a0Python Standard Library - One Language. Endless Possibilities<\/title>\n<meta name=\"description\" content=\"Explore Python Standard Library: built-in modules for math, files, JSON, dates, and more. No pip needed, ready for professional projects.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/python\/lesson\/python-standard-library\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u00a0Python Standard Library - One Language. Endless Possibilities\" \/>\n<meta property=\"og:description\" content=\"Explore Python Standard Library: built-in modules for math, files, JSON, dates, and more. No pip needed, ready for professional projects.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/python\/lesson\/python-standard-library\/\" \/>\n<meta property=\"og:site_name\" content=\"One Language. Endless Possibilities\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-14T05:03:35+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/python-standard-library\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/python-standard-library\\\/\",\"name\":\"\u00a0Python Standard Library - One Language. Endless Possibilities\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\"},\"datePublished\":\"2026-03-02T02:32:25+00:00\",\"dateModified\":\"2026-03-14T05:03:35+00:00\",\"description\":\"Explore Python Standard Library: built-in modules for math, files, JSON, dates, and more. No pip needed, ready for professional projects.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/python-standard-library\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/python-standard-library\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/python-standard-library\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PYTHON INTERMEDIATE (PYI) > Modules and Packages > Python Standard Library\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\",\"name\":\"One Language. Endless Possibilities\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u00a0Python Standard Library - One Language. Endless Possibilities","description":"Explore Python Standard Library: built-in modules for math, files, JSON, dates, and more. No pip needed, ready for professional projects.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/python\/lesson\/python-standard-library\/","og_locale":"en_US","og_type":"article","og_title":"\u00a0Python Standard Library - One Language. Endless Possibilities","og_description":"Explore Python Standard Library: built-in modules for math, files, JSON, dates, and more. No pip needed, ready for professional projects.","og_url":"https:\/\/gigz.pk\/python\/lesson\/python-standard-library\/","og_site_name":"One Language. Endless Possibilities","article_modified_time":"2026-03-14T05:03:35+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/python\/lesson\/python-standard-library\/","url":"https:\/\/gigz.pk\/python\/lesson\/python-standard-library\/","name":"\u00a0Python Standard Library - One Language. Endless Possibilities","isPartOf":{"@id":"https:\/\/gigz.pk\/python\/#website"},"datePublished":"2026-03-02T02:32:25+00:00","dateModified":"2026-03-14T05:03:35+00:00","description":"Explore Python Standard Library: built-in modules for math, files, JSON, dates, and more. No pip needed, ready for professional projects.","breadcrumb":{"@id":"https:\/\/gigz.pk\/python\/lesson\/python-standard-library\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/python\/lesson\/python-standard-library\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/python\/lesson\/python-standard-library\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/python\/"},{"@type":"ListItem","position":2,"name":"PYTHON INTERMEDIATE (PYI) > Modules and Packages > Python Standard Library"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/python\/#website","url":"https:\/\/gigz.pk\/python\/","name":"One Language. Endless Possibilities","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/media?parent=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}