{"id":130450,"date":"2023-05-11T11:00:58","date_gmt":"2023-05-11T05:30:58","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?page_id=130450"},"modified":"2024-04-12T14:34:03","modified_gmt":"2024-04-12T09:04:03","slug":"default-argument-values-and-keyword-arguments","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/","title":{"rendered":"<a href=\"http:\/\/vskills.in\/certification\/tutorial\/information-technology\/python-developer\/default-argument-values-and-keyword-arguments\/\" target=\"_blank\" rel=\"noreferrer noopener\">Default Argument values and keyword arguments<\/a>"},"content":{"rendered":"\n<p><strong>Default Argument values and keyword arguments<\/strong><\/p>\n\n\n\n<p>In Python, functions can have default argument values and keyword arguments.<\/p>\n\n\n\n<p>Default argument values are values that are assigned to function parameters when they are declared. If a value is not passed for that parameter when the function is called, the default value will be used instead. Here&#8217;s an example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pythonCopy code<code>def greet(name, greeting=\"Hello\"):\n    print(greeting, name)\n\ngreet(\"Alice\")   # Output: Hello Alice\ngreet(\"Bob\", \"Hi\")  # Output: Hi Bob\n<\/code><\/pre>\n\n\n\n<p>In the above example, the <code>greeting<\/code> parameter has a default value of &#8220;Hello&#8221;. When <code>greet<\/code> is called with just the <code>name<\/code> argument, the default value is used. When <code>greet<\/code> is called with both <code>name<\/code> and <code>greeting<\/code>, the <code>greeting<\/code> argument overrides the default value.<\/p>\n\n\n\n<p>Keyword arguments are arguments passed to a function with a specific name or keyword. They are useful when you want to specify values for specific parameters without worrying about the order in which they are passed. Here&#8217;s an example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pythonCopy code<code>def power(base, exponent):\n    return base ** exponent\n\nresult1 = power(2, 3)    # Output: 8\nresult2 = power(exponent=3, base=2)  # Output: 8\n<\/code><\/pre>\n\n\n\n<p>In the above example, we define a function <code>power<\/code> that takes two arguments, <code>base<\/code> and <code>exponent<\/code>. In the first call to <code>power<\/code>, we pass the arguments in the order they are defined in the function signature. In the second call, we pass the arguments using the keyword <code>exponent<\/code> and <code>base<\/code>, which allows us to pass them in any order.<\/p>\n\n\n\n<p>Note that default argument values and keyword arguments are optional features in Python, and not every function needs to use them. However, they can make your code more readable and easier to use.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Apply for Python Certification!<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/www.vskills.in\/certification\/certified-python-developer\">https:\/\/www.vskills.in\/certification\/certified-python-developer<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/python-developer\/\" target=\"_blank\" rel=\"noreferrer noopener\">Back to Tutorials<\/a><\/strong><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>Default Argument values and keyword arguments In Python, functions can have default argument values and keyword arguments. Default argument values are values that are assigned to function parameters when they are declared. If a value is not passed for that parameter when the function is called, the default value will be used instead. Here&#8217;s an&#8230;<\/p>\n","protected":false},"author":23,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[252],"tags":[],"class_list":["post-130450","page","type-page","status-publish","hentry","category-python-developer"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Default Argument values and keyword arguments - Tutorial<\/title>\n<meta name=\"description\" content=\"Default Argument values and keyword arguments\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Default Argument values and keyword arguments - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Default Argument values and keyword arguments\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T09:04:03+00:00\" \/>\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\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/\",\"name\":\"Default Argument values and keyword arguments - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2023-05-11T05:30:58+00:00\",\"dateModified\":\"2024-04-12T09:04:03+00:00\",\"description\":\"Default Argument values and keyword arguments\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Default Argument values and keyword arguments\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Default Argument values and keyword arguments - Tutorial","description":"Default Argument values and keyword arguments","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:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/","og_locale":"en_US","og_type":"article","og_title":"Default Argument values and keyword arguments - Tutorial","og_description":"Default Argument values and keyword arguments","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T09:04:03+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/","name":"Default Argument values and keyword arguments - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2023-05-11T05:30:58+00:00","dateModified":"2024-04-12T09:04:03+00:00","description":"Default Argument values and keyword arguments","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/default-argument-values-and-keyword-arguments\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Default Argument values and keyword arguments"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/130450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=130450"}],"version-history":[{"count":2,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/130450\/revisions"}],"predecessor-version":[{"id":130454,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/130450\/revisions\/130454"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=130450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=130450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=130450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}