{"id":451,"date":"2025-05-20T04:51:26","date_gmt":"2025-05-20T04:51:26","guid":{"rendered":"https:\/\/buhave.com\/courses\/?p=451"},"modified":"2026-06-25T07:46:37","modified_gmt":"2026-06-25T07:46:37","slug":"functions","status":"publish","type":"post","link":"https:\/\/buhave.com\/courses\/python\/functions\/","title":{"rendered":"Functions"},"content":{"rendered":"<h2><strong>Defining and calling functions<\/strong><span style=\"font-weight: 400\"><br \/>\n<\/span><\/h2>\n<p><strong>What Are Functions?<\/strong><\/p>\n<p>A function is a block of reusable code that performs a specific task. You define functions to avoid repeating code, enhance readability, and make your code more modular. In Python tutorials such as Introduction to Python, you\u2019ll see these concepts demonstrated. For a quick refresher on how variables interact with functions, see the <a href=\"https:\/\/buhave.com\/courses\/python\/variables-data-types-and-operators\/\" title=\"Variables, Data Types and Operators course\">Variables, Data Types and Operators<\/a> lesson.<\/p>\n<h3>1. Defining a Function<\/h3>\n<p>To define a function, you use the def keyword followed by the function name, parentheses, and a colon (:). The indented code that follows is the body of the function, where the logic happens.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p style=\"text-align: center\"><em>def function_name(parameters):<\/em><br \/>\n<em># function body<\/em><br \/>\n<em># code to be executed<\/em><\/p>\n<p><strong>Example 1:<\/strong> A Simple Function<\/p>\n<p style=\"text-align: center\"><em>def greet():<\/em><br \/>\n<em>print(&quot;Hello, welcome!&quot;)<\/em><\/p>\n<ul>\n<li>def defines the function.<\/li>\n<li>greet() is the function name.<\/li>\n<li>The body contains the print() statement.<\/li>\n<\/ul>\n<p>This function doesn\u2019t accept any parameters and simply prints a message when called.<\/p>\n<p>For a deeper look at how Python handles scope and functions, you can explore the <a href=\"https:\/\/buhave.com\/courses\/java-script\/functions-and-scope\/\" title=\"Functions and Scope course\">Functions and Scope<\/a> lesson.<\/p>\n<h3>2. Calling a Function<\/h3>\n<p>After defining a function, you can call it by using its name followed by parentheses. This behavior is explored in more depth in the <a href=\"https:\/\/buhave.com\/courses\/java-script\/functions-and-scope\/\" title=\"Functions and Scope course\">Functions and Scope<\/a> lesson. For beginners, see the <a href=\"https:\/\/buhave.com\/courses\/python\/introduction-to-python\/\" title=\"Introduction to Python course\">Introduction to Python<\/a> course for a gentle introduction.<\/p>\n<h3>3. Functions with Parameters<\/h3>\n<p>Functions can accept parameters \u2014 values that are passed into the function when it\u2019s called. For a deeper look at parameters and how they relate to scope, see <a href=\"https:\/\/buhave.com\/courses\/java-script\/functions-and-scope\/\" title=\"Functions and Scope course\">Functions and Scope<\/a>.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p style=\"text-align: center\"><em>def function_name(parameter1, parameter2):<\/em><br \/>\n<em># code<\/em><\/p>\n<p><strong>Example 3:<\/strong> Function with Parameters<\/p>\n<p style=\"text-align: center\"><em>def greet(name):<\/em><br \/>\n<em>print(f&quot;Hello, {name}!&quot;)<\/em><\/p>\n<p><strong>Calling the Function with an Argument<\/strong><\/p>\n<p style=\"text-align: center\"><em>greet(&quot;Alice&quot;)<\/em><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p style=\"text-align: center\"><em>Hello, Alice!<\/em><\/p>\n<p>The function greet() accepts a name parameter and prints a personalized greeting.<\/p>\n<p>Parameters and how they map to data types are discussed in more detail in the <a href=\"https:\/\/buhave.com\/courses\/python\/variables-data-types-and-operators\/\" title=\"Variables, Data Types and Operators course\">Variables, Data Types and Operators<\/a> lesson.<\/p>\n<h3>4. Functions with Return Values<\/h3>\n<p>Functions can return a value using the return keyword, allowing you to send results back to where the function was called.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<p style=\"text-align: center\"><em>def function_name():<\/em><br \/>\n<em>return value<\/em><\/p>\n<p><strong>Example 4:<\/strong> Function with a Return Value<\/p>\n<p style=\"text-align: center\"><em>def add(a, b):<\/em><br \/>\n<em>return a + b<\/em><\/p>\n<p><strong> Calling the Function and Using the Return Value<\/strong><\/p>\n<p style=\"text-align: center\"><em>result = add(5, 3)<\/em><br \/>\n<em>print(result)<\/em><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p style=\"text-align: center\"><em>8<\/em><\/p>\n<p>The add() function returns the sum of a and b, and the result is stored in the result variable, which is then printed. This pattern of computing and returning results is common in many real-world tasks.<\/p>\n<p>For more practice with parameters, arguments, and return values, explore the <a href=\"https:\/\/buhave.com\/courses\/python\/introduction-to-python\/\" title=\"Introduction to Python course\">Introduction to Python<\/a> and <a href=\"https:\/\/buhave.com\/courses\/java-script\/functions-and-scope\/\" title=\"Functions and Scope course\">Functions and Scope<\/a> resources.<\/p>\n<p>For a quick refresher on how variables interact with functions, see the Variables, Data Types and Operators lesson.<\/p>\n<h2>Variable scope<\/h2>\n<h3>What is Variable Scope?<\/h3>\n<p>Variable scope refers to the region of a program where a variable can be accessed. In Python, the scope is influenced by where the variable is declared and where it is used.<\/p>\n<p><strong>Types of Scope in Python<\/strong><\/p>\n<ul>\n<li>Local Scope<\/li>\n<li>Enclosing Scope<\/li>\n<li>Global Scope<\/li>\n<li>Built-in Scope<\/li>\n<\/ul>\n<h3>1. Local Scope<\/h3>\n<p>A variable has local scope if it is defined inside a function or a block of code. This means it is only accessible within that function or block.<\/p>\n<ul>\n<li>Local variables are created when the function is called and destroyed when the function finishes execution.<\/li>\n<\/ul>\n<p><strong>Example of Local Scope:<\/strong><\/p>\n<p style=\"text-align: center\"><em>def my_function():<\/em><br \/>\n<em>x = 10 # x is local to my_function<\/em><br \/>\n<em>print(x)<\/em><\/p>\n<p style=\"text-align: center\"><em>my_function() # Output: 10<\/em><br \/>\n<em># print(x) # This would cause an error because x is local to my_function<\/em><\/p>\n<p>In the example, x is local to my_function(), and trying to access x outside the function will raise a NameError.<\/p>\n<h3>2. Enclosing Scope (Nonlocal)<\/h3>\n<p>Enclosing scope refers to the scope of a function within another function. Variables defined in the outer (enclosing) function are accessible to the inner (nested) function.<\/p>\n<ul>\n<li>These variables are not local to the inner function but can be modified using the nonlocal keyword.<\/li>\n<\/ul>\n<p><strong>Example of Enclosing Scope:<\/strong><\/p>\n<p style=\"text-align: center\"><em>def outer_function():<\/em><br \/>\n<em>x = 20 # x is in the enclosing scope<\/em><br \/>\n<em>def inner_function():<\/em><br \/>\n<em>print(x) # Can access x from the enclosing function<\/em><br \/>\n<em>inner_function()<\/em><\/p>\n<p style=\"text-align: center\"><em>outer_function() # Output: 20<\/em><\/p>\n<p>Here, inner_function() can access x from the outer_function() because x is in an enclosing scope.<\/p>\n<h3>3. Global Scope<\/h3>\n<p>A variable has global scope if it is defined at the top level of the script or module (outside any function). Global variables can be accessed from any part of the program, including inside functions (but not always modified directly without the global keyword).<\/p>\n<ul>\n<li>Global variables exist throughout the life of the program.<\/li>\n<\/ul>\n<p><strong>Example of Global Scope:<\/strong><\/p>\n<p style=\"text-align: center\"><em>x = 50 # x is a global variable<\/em><\/p>\n<p style=\"text-align: center\"><em>def my_function():<\/em><br \/>\n<em>print(x) # Can access global x inside the function<\/em><\/p>\n<p style=\"text-align: center\"><em>my_function() # Output: 50<\/em><br \/>\n<em>print(x) # Output: 50<\/em><\/p>\n<p>In this example, x is defined in the global scope and can be accessed inside the function my_function().<\/p>\n<p><strong>Modifying a Global Variable:<\/strong><\/p>\n<p>To modify a global variable inside a function, use the global keyword:<\/p>\n<p style=\"text-align: center\"><em>x = 50 # Global variable<\/em><\/p>\n<p style=\"text-align: center\"><em>def my_function():<\/em><br \/>\n<em>global x<\/em><br \/>\n<em>x = 100 # Modifies the global x<\/em><\/p>\n<p style=\"text-align: center\"><em>my_function()<\/em><br \/>\n<em>print(x) # Output: 100<\/em><\/p>\n<p>Without the global keyword, trying to assign to x inside the function would create a local variable x instead of modifying the global one.<\/p>\n<h3>4. Built-in Scope<\/h3>\n<p>Built-in scope refers to the names that are available in Python\u2019s built-in namespace, which includes functions like print(), len(), sum(), and more. These names are available throughout the entire program.<\/p>\n<ul>\n<li>Built<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Defining and calling functions What Are Functions? A function is a block of reusable code that performs a specific task. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":768,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[9],"tags":[],"class_list":["post-451","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Functions - Python Course<\/title>\n<meta name=\"description\" content=\"Functions are reusable blocks of code that perform specific tasks when called; they help organize code and avoid repetition.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/buhave.com\/courses\/python\/functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Functions - Python Course\" \/>\n<meta property=\"og:description\" content=\"Functions are reusable blocks of code that perform specific tasks when called; they help organize code and avoid repetition.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/buhave.com\/courses\/python\/functions\/\" \/>\n<meta property=\"og:site_name\" content=\"BUHAVE\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BeYouHave\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/naveedsafdarawan\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-20T04:51:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-25T07:46:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Functions.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Naveed Safdar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Naveed Safdar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/\"},\"author\":{\"name\":\"Naveed Safdar\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/person\\\/04fe0254e118521c9fbb3da39de5acca\"},\"headline\":\"Functions\",\"datePublished\":\"2025-05-20T04:51:26+00:00\",\"dateModified\":\"2026-06-25T07:46:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/\"},\"wordCount\":886,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Functions.webp\",\"articleSection\":[\"Python Course\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/\",\"name\":\"Functions - Python Course\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Functions.webp\",\"datePublished\":\"2025-05-20T04:51:26+00:00\",\"dateModified\":\"2026-06-25T07:46:37+00:00\",\"description\":\"Functions are reusable blocks of code that perform specific tasks when called; they help organize code and avoid repetition.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/#primaryimage\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Functions.webp\",\"contentUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Functions.webp\",\"width\":1200,\"height\":628,\"caption\":\"Functions\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/python\\\/functions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Courses\",\"item\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Course\",\"item\":\"https:\\\/\\\/buhave.com\\\/courses\\\/learn\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#website\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\",\"name\":\"BUHAVE\",\"description\":\"Courses - Learn Online for Free\",\"publisher\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/buhave.com\\\/courses\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\",\"name\":\"BUHAVE\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/buhave-course.webp\",\"contentUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/buhave-course.webp\",\"width\":375,\"height\":75,\"caption\":\"BUHAVE\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/BeYouHave\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/buhave\",\"https:\\\/\\\/www.youtube.com\\\/@buhave\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/person\\\/04fe0254e118521c9fbb3da39de5acca\",\"name\":\"Naveed Safdar\",\"description\":\"I\u2019m Naveed Safdar - SEO Manager with over 10 years of experience in SEO and Digital Marketing. I\u2019ve had the privilege of working with leading national and international companies including Grafdom, PakWheels, Systems Limited, Confiz, Educative, and Dubizzle Labs. My expertise spans technical SEO, content strategy, organic growth, and performance analytics - helping businesses improve visibility, traffic, and ROI.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/naveedsafdar\\\/\",\"https:\\\/\\\/www.facebook.com\\\/naveedsafdarawan\\\/\",\"https:\\\/\\\/www.youtube.com\\\/@naveedsafdar\"],\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/author\\\/naveed-safdar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Functions - Python Course","description":"Functions are reusable blocks of code that perform specific tasks when called; they help organize code and avoid repetition.","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:\/\/buhave.com\/courses\/python\/functions\/","og_locale":"en_US","og_type":"article","og_title":"Functions - Python Course","og_description":"Functions are reusable blocks of code that perform specific tasks when called; they help organize code and avoid repetition.","og_url":"https:\/\/buhave.com\/courses\/python\/functions\/","og_site_name":"BUHAVE","article_publisher":"https:\/\/www.facebook.com\/BeYouHave\/","article_author":"https:\/\/www.facebook.com\/naveedsafdarawan\/","article_published_time":"2025-05-20T04:51:26+00:00","article_modified_time":"2026-06-25T07:46:37+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Functions.webp","type":"image\/webp"}],"author":"Naveed Safdar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Naveed Safdar","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/buhave.com\/courses\/python\/functions\/#article","isPartOf":{"@id":"https:\/\/buhave.com\/courses\/python\/functions\/"},"author":{"name":"Naveed Safdar","@id":"https:\/\/buhave.com\/courses\/#\/schema\/person\/04fe0254e118521c9fbb3da39de5acca"},"headline":"Functions","datePublished":"2025-05-20T04:51:26+00:00","dateModified":"2026-06-25T07:46:37+00:00","mainEntityOfPage":{"@id":"https:\/\/buhave.com\/courses\/python\/functions\/"},"wordCount":886,"commentCount":0,"publisher":{"@id":"https:\/\/buhave.com\/courses\/#organization"},"image":{"@id":"https:\/\/buhave.com\/courses\/python\/functions\/#primaryimage"},"thumbnailUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Functions.webp","articleSection":["Python Course"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/buhave.com\/courses\/python\/functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/buhave.com\/courses\/python\/functions\/","url":"https:\/\/buhave.com\/courses\/python\/functions\/","name":"Functions - Python Course","isPartOf":{"@id":"https:\/\/buhave.com\/courses\/#website"},"primaryImageOfPage":{"@id":"https:\/\/buhave.com\/courses\/python\/functions\/#primaryimage"},"image":{"@id":"https:\/\/buhave.com\/courses\/python\/functions\/#primaryimage"},"thumbnailUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Functions.webp","datePublished":"2025-05-20T04:51:26+00:00","dateModified":"2026-06-25T07:46:37+00:00","description":"Functions are reusable blocks of code that perform specific tasks when called; they help organize code and avoid repetition.","breadcrumb":{"@id":"https:\/\/buhave.com\/courses\/python\/functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/buhave.com\/courses\/python\/functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buhave.com\/courses\/python\/functions\/#primaryimage","url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Functions.webp","contentUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Functions.webp","width":1200,"height":628,"caption":"Functions"},{"@type":"BreadcrumbList","@id":"https:\/\/buhave.com\/courses\/python\/functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Courses","item":"https:\/\/buhave.com\/courses\/"},{"@type":"ListItem","position":2,"name":"Python Course","item":"https:\/\/buhave.com\/courses\/learn\/python\/"},{"@type":"ListItem","position":3,"name":"Functions"}]},{"@type":"WebSite","@id":"https:\/\/buhave.com\/courses\/#website","url":"https:\/\/buhave.com\/courses\/","name":"BUHAVE","description":"Courses - Learn Online for Free","publisher":{"@id":"https:\/\/buhave.com\/courses\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/buhave.com\/courses\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/buhave.com\/courses\/#organization","name":"BUHAVE","url":"https:\/\/buhave.com\/courses\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buhave.com\/courses\/#\/schema\/logo\/image\/","url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/03\/buhave-course.webp","contentUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/03\/buhave-course.webp","width":375,"height":75,"caption":"BUHAVE"},"image":{"@id":"https:\/\/buhave.com\/courses\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/BeYouHave\/","https:\/\/www.linkedin.com\/company\/buhave","https:\/\/www.youtube.com\/@buhave"]},{"@type":"Person","@id":"https:\/\/buhave.com\/courses\/#\/schema\/person\/04fe0254e118521c9fbb3da39de5acca","name":"Naveed Safdar","description":"I\u2019m Naveed Safdar - SEO Manager with over 10 years of experience in SEO and Digital Marketing. I\u2019ve had the privilege of working with leading national and international companies including Grafdom, PakWheels, Systems Limited, Confiz, Educative, and Dubizzle Labs. My expertise spans technical SEO, content strategy, organic growth, and performance analytics - helping businesses improve visibility, traffic, and ROI.","sameAs":["https:\/\/www.linkedin.com\/in\/naveedsafdar\/","https:\/\/www.facebook.com\/naveedsafdarawan\/","https:\/\/www.youtube.com\/@naveedsafdar"],"url":"https:\/\/buhave.com\/courses\/author\/naveed-safdar\/"}]}},"_links":{"self":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/comments?post=451"}],"version-history":[{"count":3,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/451\/revisions"}],"predecessor-version":[{"id":1286,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/451\/revisions\/1286"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/media\/768"}],"wp:attachment":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/media?parent=451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/categories?post=451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/tags?post=451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}