function + default argument | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

function + default argument

i am wondering why i keep getting a wrong sum when i call "shuttle ()" in the code below https://code.sololearn.com/cNYePLBqU2j8/?ref=app

3rd Apr 2018, 5:25 AM
Doe Dare Oladimeji
Doe Dare Oladimeji - avatar
2 Answers
+ 1
Well, the sum is correct. When you call your function without arguments, it takes default (3+4). so x = (6**2)*(3+4) = 252
3rd Apr 2018, 5:31 AM
strawdog
strawdog - avatar
0
thanks. that made clearer. My initial thought was that it was gonna return only the sum in the bracket i.e. 3+4
3rd Apr 2018, 5:37 AM
Doe Dare Oladimeji
Doe Dare Oladimeji - avatar