In this python function program, we will create a function with *args as parameters.
What is *args?
*args allows us to pass a variable number of non-keyword arguments to a Python function.
What is Function?
It is a block of code that executes when it is called.
To create a function use def keyword.
Steps to solve the program
- Create a function func
- Use the def keyword to define the function.
- Pass multiple parameters to the function using *args.
*args is used to pass multiple objects to the function. - Use a for loop to iterate numbers and print the cube of each number.
- Pass multiple numbers to the function while calling the function.
def func(*args):
for num in args:
print(num**3,end=" ")
func(5,6,8,7)
Output :
125 216 512 343
Related Articles
Python function program to get the factorial of a given number.
Python function program to get the Fibonacci series up to the given number.
Python function program to get unique values from the given list.
Python function program to get the duplicate characters from the string.
Python function program to get the square of all values in the given dictionary.