Can any one explain the default values with another easy example? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can any one explain the default values with another easy example?

2nd May 2020, 2:53 PM
supriya
supriya - avatar
2 Answers
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
2nd May 2020, 3:26 PM
Slick
Slick - avatar