Created
September 3, 2022 17:31
-
-
Save iKunalmathur/960155be56ce0957ae8071939e6bb3f6 to your computer and use it in GitHub Desktop.
how *ARGS and **KWARGS work in PYTHON FUNCTIONS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def adder(*num): | |
sum = 0 | |
for n in num: | |
sum = sum + n | |
print("Sum:",sum) | |
adder(3,5) | |
adder(4,5,6,7) | |
adder(1,2,3,5,6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def intro(**data): | |
print("\nData type of argument:",type(data)) | |
for key, value in data.items(): | |
print("{} is {}".format(key,value)) | |
intro(Firstname="Sita", Lastname="Sharma", Age=22, Phone=1234567890) | |
intro(Firstname="John", Lastname="Wood", Email="johnwood@nomail.com", Country="Wakanda", Age=25, Phone=9876543210) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment