{"id":1,"date":"2022-11-18T12:49:42","date_gmt":"2022-11-18T12:49:42","guid":{"rendered":"https:\/\/blog.metu.edu.tr\/e243521\/?p=1"},"modified":"2022-11-26T11:32:31","modified_gmt":"2022-11-26T11:32:31","slug":"hello-world","status":"publish","type":"post","link":"https:\/\/blog.metu.edu.tr\/e243521\/2022\/11\/18\/hello-world\/","title":{"rendered":"Arguments in Python"},"content":{"rendered":"\n<p>Functions accept arguments that can contain data. The function name is followed by parenthesis that list the arguments. Simply separate each argument with a comma to add as many as you like. <\/p>\n\n\n\n<p>Example 1: Python Function Arguments:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"442\" height=\"295\" src=\"https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/a1.jpg\" alt=\"\" class=\"wp-image-36\" srcset=\"https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/a1.jpg 442w, https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/a1-300x200.jpg 300w, https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/a1-272x182.jpg 272w\" sizes=\"auto, (max-width: 442px) 100vw, 442px\" \/><\/figure>\n\n\n\n<p>In the above example, the function&nbsp;<code>add_numbers()<\/code>&nbsp;takes two parameters:&nbsp;<code>a<\/code>&nbsp;and&nbsp;<code>b<\/code>.<\/p>\n\n\n\n<p><strong>Function Argument with Default Values:<\/strong><\/p>\n\n\n\n<p>In Python, we can provide default values to function arguments. We use the&nbsp;<code>=<\/code>&nbsp;operator to provide default values<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"475\" height=\"409\" src=\"https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/a2.jpg\" alt=\"\" class=\"wp-image-37\" srcset=\"https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/a2.jpg 475w, https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/a2-300x258.jpg 300w\" sizes=\"auto, (max-width: 475px) 100vw, 475px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/ao1.jpg\" alt=\"\" class=\"wp-image-38\" width=\"207\" height=\"135\" \/><\/figure>\n\n\n\n<p>In the above example, the function definition Here, we have provided default values&nbsp;<strong>7<\/strong>&nbsp;and&nbsp;<strong>8<\/strong>&nbsp;for parameters a and b respectively.<\/p>\n\n\n\n<p><strong>Python Keyword Argument<\/strong><\/p>\n\n\n\n<p>A function must always be called with the appropriate number of parameters by default. In other words, if your function requires 2 arguments, you must call it with 2 arguments, not more or fewer.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"739\" height=\"196\" src=\"https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/a3.jpg\" alt=\"\" class=\"wp-image-39\" srcset=\"https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/a3.jpg 739w, https:\/\/blog.metu.edu.tr\/e243521\/files\/2022\/11\/a3-300x80.jpg 300w\" sizes=\"auto, (max-width: 739px) 100vw, 739px\" \/><\/figure>\n\n\n\n<p>First name from the function declaration is paired with first name from the function call. Similar to how last name in the function specification corresponds to last name in the function call.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Functions accept arguments that can contain data. The function name is followed by parenthesis that list the arguments. Simply separate each argument with a comma to add as many as you like. Example 1: Python Function Arguments: In the above example, the function&nbsp;add_numbers()&nbsp;takes two parameters:&nbsp;a&nbsp;and&nbsp;b. Function Argument with Default Values: In Python, we can provide [&hellip;]<\/p>\n","protected":false},"author":8584,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[1],"tags":[],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-all-tutorial"],"_links":{"self":[{"href":"https:\/\/blog.metu.edu.tr\/e243521\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.metu.edu.tr\/e243521\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.metu.edu.tr\/e243521\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/e243521\/wp-json\/wp\/v2\/users\/8584"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/e243521\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":0,"href":"https:\/\/blog.metu.edu.tr\/e243521\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.metu.edu.tr\/e243521\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/e243521\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/e243521\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}