+ 1
Basic Python function needing explanation
Hi guys, I need some clarification in how this function works. def add_num(num_1 = 10): return num_1 + num_1 print(add_num(100)) My incorrect answer was 100. I thought the return keyword would replace the parameter with 20, num_1 =10 + num_1 =10, but the 100 in the print function would over ride some how. THis is where I am lost. Can I get some clarity on how this is program returns 200?
2 Respostas
+ 7
i think 10 is the default value if u dont pass a parameter.
In this case u pass 100 and num_1 is 100.
the function returns 100 + 100 = 200
- 4
I love python language