Arbitrary Arguments and Keyword Argument in Python

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

#Arbitrary Arguments and Key Arguments

# def display(*args): 
#     for x in args:
#         print(x)
    
# def display(*args):
#       m=len(args)
#       i=0
#       while(i<m): 
#             print(args[i])
#             i+=1


#calling
# display(10,20,30,40,50,60,70,80,20,30)
# display(101,"Vishal Sharma",89.99,True)

# def addition(*args):
#     sum=0
#     for x in args:
#         sum=sum+x
#     return sum

# #calling
# s=addition(10,20,30)        
# print("Additon is",s)

# KEY Arguments

def display(car1,car2,car3):
    print(car1)
    print(car2)
    print(car3)


#Calling
display("Maruti","Hundai","Kia")
print("-----------------------------------------")
display(car3="Maruti",car1="Hundai",car2="Kia")

 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *