python set default parameters code example
Example 1: python default arguments
def my_function(name, age = 20):
print(name + " is " + str(age) + " years old"
my_function("Mitro")
my_function("Mitro", 26)
Example 2: set default python
newDict = {1:"One",
2:"Two",
3:"Three"}
x=newDict.setdefault(4,"Four")
print(newDict[4])
newDict2 = {1:"One",
2:"Two",
3:"Three",
"Hello":"World"}
y=newDict.setdefault("Hello","Yellow")
print(newDict2["Hello"])
dict1 = {1:"One",2:"Two"}
x=dict1.setdefault(3,"Three")
x=dict1.setdefault(2,"Duo")
print(dict1)