PYnative

Python Programming

  • Learn Python
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises
    • Python Exercises
    • C Programming Exercises
    • C++ Exercises
  • Quizzes
  • Code Editor
    • Online Python Code Editor
    • Online C Compiler
    • Online C++ Compiler
Home » Python » Basics » Python Function Arguments

Python Function Arguments

Updated on: August 2, 2022 | 13 Comments

This article explains Python’s various function arguments with clear examples of how to use them. But before learning all function arguments in detail, first, understand the use of argument or parameter in the function.

Also, See

  • Python Functions Exercise
  • Python Functions Quiz

Table of contents

  • What is a function argument?
    • Types of function arguments
  • Default Arguments
  • Keyword Arguments
  • Positional Arguments
  • Important points to remember about function argument
  • Variable-length arguments
    • Arbitrary positional arguments (*args)
    • Arbitrary keyword arguments (**kwargs)

What is a function argument?

When we define and call a Python function, the term parameter and argument is used to pass information to the function.

  • parameter: It is the variable listed inside the parentheses in the function definition.
  • argument: It is a value sent to the function when it is called. It is data on which function performs some action and returns the result.

Example:

In this example, the function sum_marks() is defined with three parameters, a, b, c, and print the sum of all three values of the arguments passed during a function call.

# a, b, c are arguments of the function
def my_sum(a, b, c):
    s = a + b + c
    return s

print('Total is:', my_sum(30, 40, 50))Code language: Python (python)

Output:

Total is: 120