{"id":113818,"date":"2026-06-08T07:41:36","date_gmt":"2026-06-08T02:11:36","guid":{"rendered":"https:\/\/www.guvi.in\/blog\/?p=113818"},"modified":"2026-06-08T07:41:38","modified_gmt":"2026-06-08T02:11:38","slug":"what-is-an-argument-in-python","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/what-is-an-argument-in-python\/","title":{"rendered":"What is an argument in Python: Types, Examples"},"content":{"rendered":"\n<p>Functions are essential in Python. They help developers organize code, avoid repetition, and create reusable logic for different tasks.<\/p>\n\n\n\n<p>Functions become truly useful when they can accept input values. This is where arguments come in. Whether you are passing a user&#8217;s name, calculating a total, or building a flexible API, arguments let functions work with different data without changing the function itself.<\/p>\n\n\n\n<p>In this article, you&#8217;ll learn what an argument in Python is, how it differs from a parameter, the various types of arguments available, and advanced concepts like *args and **kwargs with practical examples.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>TL;DR<\/strong><\/h2>\n\n\n\n<ol>\n<li>An argument in Python is a value passed to a function when it is called.<\/li>\n\n\n\n<li>Arguments help functions accept different inputs and produce dynamic results.<\/li>\n\n\n\n<li>Python supports positional, keyword, default, *args, and **kwargs arguments.<\/li>\n\n\n\n<li>Understanding arguments helps you write more flexible, reusable, and maintainable Python code.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is an argument in Python?<\/strong><\/h2>\n\n\n\n<p>An argument in Python is a value that is passed to a function when the function is called. Arguments provide input data that the function can use to perform a specific task.<\/p>\n\n\n\n<p>Consider the following example:<\/p>\n\n\n\n<p>def greet(name):<br>print(f&#8221;Hello, {name}&#8221;)<\/p>\n\n\n\n<p>greet(&#8220;Harini&#8221;)<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>Hello, Harini<\/p>\n\n\n\n<p>In this example, &#8220;Harini&#8221; is the argument passed to the function.<\/p>\n\n\n\n<p>Without arguments, functions would always produce the same result. Arguments make functions dynamic and reusable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Arguments vs Parameters in Python<\/strong><\/h2>\n\n\n\n<p>Many beginners confuse arguments and parameters, but they mean different things.<\/p>\n\n\n\n<p>A parameter is the <a href=\"https:\/\/www.guvi.in\/hub\/python-tutorial\/variables\/\" target=\"_blank\" rel=\"noreferrer noopener\">variable<\/a> listed in the function definition.<\/p>\n\n\n\n<p>An argument is the actual value passed when the <a href=\"https:\/\/www.guvi.in\/hub\/python\/functions-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">function<\/a> is called.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>def greet(name):<br>print(name)<\/p>\n\n\n\n<p>greet(&#8220;Harini&#8221;)<\/p>\n\n\n\n<p>Here:<\/p>\n\n\n\n<p>\u2022 name is a parameter<\/p>\n\n\n\n<p>\u2022 &#8220;Harini&#8221; is an argument<\/p>\n\n\n\n<p>Understanding this distinction is important as you work with larger programs and reusable functions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why Are Arguments Important?<\/strong><\/h2>\n\n\n\n<p>Arguments allow a single function to work with different inputs.<\/p>\n\n\n\n<p>Instead of creating separate functions for each user, you can use one function and pass different arguments whenever needed.<\/p>\n\n\n\n<p>def welcome(user):<br>print(f&#8221;Welcome, {user}&#8221;)<\/p>\n\n\n\n<p>welcome(&#8220;Harini&#8221;)<br>welcome(&#8220;John&#8221;)<br>welcome(&#8220;Priya&#8221;)<\/p>\n\n\n\n<p>This approach makes code more scalable and easier to maintain.<\/p>\n\n\n\n<p>You can also download <strong>HCL GUVI\u2019s<\/strong> <a href=\"https:\/\/www.guvi.in\/mlp\/python-ebook\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=What+is+an+argument+in+Python%3A+Types%2C+Examples\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Python ebook<\/strong><\/a> to learn more about Python arguments, loops, functions, and beginner-friendly Python programs in one place.\u00a0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Types of Arguments in Python<\/strong><\/h2>\n\n\n\n<p>Python supports several types of arguments:<\/p>\n\n\n\n<p>\u2022 Positional Arguments<\/p>\n\n\n\n<p>\u2022 Keyword Arguments<\/p>\n\n\n\n<p>\u2022 Default Arguments<\/p>\n\n\n\n<p>\u2022 Arbitrary Arguments (*args)<\/p>\n\n\n\n<p>\u2022 Arbitrary Keyword Arguments (**kwargs)<\/p>\n\n\n\n<p>Let&#8217;s explore each type.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Positional Arguments<\/strong><\/h2>\n\n\n\n<p>Positional arguments are assigned to parameters based on their order.<\/p>\n\n\n\n<p>def student(name, age):<br>print(name, age)<\/p>\n\n\n\n<p>student(&#8220;Harini&#8221;, 23)<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>Harini 23<\/p>\n\n\n\n<p>The first argument is assigned to the first parameter, and the second argument is assigned to the second parameter.<\/p>\n\n\n\n<p>If the order changes, the output changes as well.<\/p>\n\n\n\n<p>student(23, &#8220;Harini&#8221;)<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>23 Harini<\/p>\n\n\n\n<p>This shows why positional order matters.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Keyword Arguments<\/strong><\/h2>\n\n\n\n<p><a href=\"https:\/\/www.guvi.in\/hub\/python\/keyword-arguments-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Keyword arguments<\/a> specify which parameter should receive a value.<\/p>\n\n\n\n<p>def student(name, age):<br>print(name, age)<\/p>\n\n\n\n<p>student(age=23, name=&#8221;Harini&#8221;)<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>Harini 23<\/p>\n\n\n\n<p>Since parameter names are provided, the order no longer matters.<\/p>\n\n\n\n<p>Keyword arguments improve readability, especially when functions have many parameters.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Default Arguments<\/strong><\/h2>\n\n\n\n<p><a href=\"https:\/\/www.guvi.in\/hub\/python\/default-parameters-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Default arguments<\/a> let you define a fallback value for a parameter.<\/p>\n\n\n\n<p>def student(name, age=18):<br>print(name, age)<\/p>\n\n\n\n<p>student(&#8220;Harini&#8221;)<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>Harini 18<\/p>\n\n\n\n<p>You can also override the default value.<\/p>\n\n\n\n<p>student(&#8220;Harini&#8221;, 23)<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>Harini 23<\/p>\n\n\n\n<p>Default arguments make functions more flexible by reducing the number of required inputs.<\/p>\n\n\n\n<div style=\"background-color: #099f4e; border: 3px solid #110053; border-radius: 12px; padding: 18px 22px; color: #FFFFFF; font-size: 18px; font-family: Montserrat, Helvetica, sans-serif; line-height: 1.6; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); max-width: 750px;\">\n  <strong style=\"font-size: 22px; color: #FFFFFF;\">\ud83d\udca1 Did You Know?<\/strong>\n  <p style=\"margin-top: 14px; margin-bottom: 0;\">\n    <strong style=\"color: #FFFFFF;\">Python<\/strong> allows functions to accept a variable number of arguments through <strong style=\"color: #FFFFFF;\">*args<\/strong> and <strong style=\"color: #FFFFFF;\">**kwargs<\/strong>. The <strong style=\"color: #FFFFFF;\">*args<\/strong> syntax collects extra positional arguments into a tuple, while <strong style=\"color: #FFFFFF;\">**kwargs<\/strong> gathers additional keyword arguments into a dictionary. This flexibility is heavily used in frameworks such as <strong style=\"color: #FFFFFF;\">Django<\/strong>, <strong style=\"color: #FFFFFF;\">Flask<\/strong>, and <strong style=\"color: #FFFFFF;\">FastAPI<\/strong>, where functions and decorators often need to handle an unknown number of inputs. Mastering these argument types is an important step toward writing scalable, reusable, and production-ready Python code.\n  <\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Arbitrary Arguments Using *args<\/strong><\/h2>\n\n\n\n<p>Sometimes you may not know how many arguments will be passed to a function.<\/p>\n\n\n\n<p>In such cases, use *args.<\/p>\n\n\n\n<p>def total(*numbers):<br>print(numbers)<\/p>\n\n\n\n<p>total(10, 20, 30, 40)<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>(10, 20, 30, 40)<\/p>\n\n\n\n<p>Python collects all positional arguments into a tuple.<\/p>\n\n\n\n<p>A more practical example:<\/p>\n\n\n\n<p>def total(*numbers):<br>return sum(numbers)<\/p>\n\n\n\n<p>print(total(10, 20, 30))<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>60<\/p>\n\n\n\n<p>This way is useful for handling an unknown number of inputs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Arbitrary Keyword Arguments Using **kwargs<\/strong><\/h2>\n\n\n\n<p>The **kwargs syntax allows a function to accept multiple keyword arguments.<\/p>\n\n\n\n<p>def profile(**details):<br>print(details)<\/p>\n\n\n\n<p>profile(name=&#8221;Harini&#8221;, role=&#8221;Developer&#8221;)<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>{&#8216;name&#8217;: &#8216;Harini&#8217;, &#8216;role&#8217;: &#8216;Developer&#8217;}<\/p>\n\n\n\n<p>Python stores the arguments in a dictionary.<\/p>\n\n\n\n<p>This makes **kwargs useful for working with dynamic configurations and user-defined data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Positional Only and Keyword Only Arguments<\/strong><\/h2>\n\n\n\n<p>Python gives you more control over how arguments are passed.<\/p>\n\n\n\n<p>def user(name, \/, *, city):<br>print(name, city)<\/p>\n\n\n\n<p>user(&#8220;Harini&#8221;, city=&#8221;Chennai&#8221;)<\/p>\n\n\n\n<p>Here:<\/p>\n\n\n\n<p>\u2022 name is positional only<\/p>\n\n\n\n<p>\u2022 city is a keyword only<\/p>\n\n\n\n<p>This feature is commonly used in modern <a href=\"https:\/\/www.guvi.in\/blog\/what-is-a-python-library\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python libraries<\/a> to improve <a href=\"https:\/\/www.guvi.in\/hub\/network-programming-with-python\/understanding-apis\/\" target=\"_blank\" rel=\"noreferrer noopener\">API<\/a> design and avoid mistakes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Common Errors While Passing Arguments<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Missing Required Arguments<\/strong><\/h3>\n\n\n\n<p>def greet(name):<br>print(name)<\/p>\n\n\n\n<p>greet()<\/p>\n\n\n\n<p>Error:<\/p>\n\n\n\n<p>TypeError<\/p>\n\n\n\n<p>The required argument was not provided.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Too Many Arguments<\/strong><\/h3>\n\n\n\n<p>def greet(name):<br>print(name)<\/p>\n\n\n\n<p>greet(&#8220;Harini&#8221;, 23)<\/p>\n\n\n\n<p>Error:<\/p>\n\n\n\n<p>TypeError<\/p>\n\n\n\n<p>The function received more arguments than expected.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Duplicate Values<\/strong><\/h3>\n\n\n\n<p>def student(name):<br>print(name)<\/p>\n\n\n\n<p>student(&#8220;Harini&#8221;, name=&#8221;Priya&#8221;)<\/p>\n\n\n\n<p>Error:<\/p>\n\n\n\n<p>TypeError<\/p>\n\n\n\n<p>Python receives two values for the same parameter.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Best Practices for Using Arguments<\/strong><\/h2>\n\n\n\n<ol>\n<li>Use descriptive parameter names that clearly describe their purpose.<\/li>\n\n\n\n<li>Prefer keyword arguments when functions have many parameters.<\/li>\n\n\n\n<li>Use default arguments for commonly used values.<\/li>\n\n\n\n<li>Avoid excessive use of *args and **kwargs when explicit parameters provide better readability.<\/li>\n\n\n\n<li>Validate user inputs when building production applications.<\/li>\n\n\n\n<li>Keep function signatures simple and easy to understand.<\/li>\n<\/ol>\n\n\n\n<p>Curious about how these concepts work in real life? Join <strong>HCL GUVI\u2019s<\/strong> <a href=\"https:\/\/www.guvi.in\/courses\/programming\/python-zero-to-hero\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=What+is+an+argument+in+Python%3A+Types%2C+Examples\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Python<\/strong><\/a> course to build Python projects and learn automation, backend development, and data science fundamentals.\u00a0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Arguments are the mechanism for passing data into Python functions. They make functions dynamic, reusable, and able to handle different inputs without rewriting code.<\/p>\n\n\n\n<p>As you move from beginner to intermediate Python development, understanding positional arguments, keyword arguments, default arguments, *args, and **kwargs becomes essential.<\/p>\n\n\n\n<p>These concepts not only improve code flexibility but also prepare you for working with real-world Python frameworks and applications.<\/p>\n\n\n\n<p>Mastering function arguments is a small step that can greatly enhance the quality and maintainability of your Python programs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>FAQs<\/strong><\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1780373572487\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>1. What is an argument in Python?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>An argument is a value passed to a function when the function is called.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1780373577654\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>2. What is the difference between arguments and parameters?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Parameters are variables defined in the function declaration, while arguments are the actual values passed during the function call.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1780373585913\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>3. What are positional arguments in Python?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Positional arguments assign values to parameters based on the order in which they are passed.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1780373595629\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>4. What is *args in Python?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>*args allows a function to accept a variable number of positional arguments and stores them in a tuple.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1780373605017\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>5. What are **kwargs in Python?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>**kwargs let a function accept a variable number of keyword arguments and store them in a dictionary.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Functions are essential in Python. They help developers organize code, avoid repetition, and create reusable logic for different tasks. Functions become truly useful when they can accept input values. This is where arguments come in. Whether you are passing a user&#8217;s name, calculating a total, or building a flexible API, arguments let functions work with [&hellip;]<\/p>\n","protected":false},"author":63,"featured_media":115240,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[717],"tags":[],"views":"28","authorinfo":{"name":"Vishalini Devarajan","url":"https:\/\/www.guvi.in\/blog\/author\/vishalini\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/06\/what-is-an-argument-in-python-300x115.webp","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/113818"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=113818"}],"version-history":[{"count":2,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/113818\/revisions"}],"predecessor-version":[{"id":115241,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/113818\/revisions\/115241"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/115240"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=113818"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=113818"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=113818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}