Program to create a function with *args as parameters

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
  1. Create a function func
  2. Use the def keyword to define the function.
  3. Pass multiple parameters to the function using *args.
    *args is used to pass multiple objects to the function.
  4. Use a for loop to iterate numbers and print the cube of each number.
  5. 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

find the HCF of two numbers.

get the factorial of a given number.

Leave a Comment