0
Can any one explain the default values with another easy example?
2 Respostas
0
w3schools explains it with example
https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/gloss_python_function_default_parameter.asp
0
Setting up an "hours & minutes to
seconds" function. Since i dont need to take seconds but may want the option in the future, add "sec" parameter and set the default value to zero. Thats so when the function is called, seconds dont NEED to be supplied. Hours and minutes will
def to_sec(hr,min,sec=0):
hr *= 3600
min *= 60
return str(hr + min + sec) + 'Total seconds'
print(to_sec(2,30)) <--Thats the call without the seconds value so it reverted to the default value 0