Python (multiple arguments
I have followed the steps for multiple arguments functions but i got an error
def subtract_bc(a,b,c):
result = a-b*c
print ('parameter a eqauls',a)
print('parameter b equals',b)
print('parameter c equals',c)
return result
i executed as subtract_bc(10,3,2), i was that the above was not defined
5 answers ( 0 marked as helpful)
Hi Lambert!
Thanks for reaching out.
It seems that you have used other symbols, not single quotes. Remember that we need single quotes (or double quotes) to indicate a string value.
Please retry with the following code.
def subtract_bc(a,b,c): result = a-b*c print ('parameter a eqauls',a) print ('parameter b equals',b) print ('parameter c equals',c) return result
Hope this helps.
Best,
Martin
Hi Lambert!
Please use the Add Media button to do that.
Hope this helps.
Best,
Martin
Best,
Martin
Hi Lambert!
All you need to do is execute the code cell containing the code we mentioned above, i.e. the one that will define the subtract_bc() function. For the moment, you have only written code. However, without executing it, your computer cannot know what function subtract_bc() is when you are referring to it later.
Hope this helps.
Best,
Martin
Best,
Martin
As requested this ,the error code i got
Hi Lambert,
The function in question is not defined, because you haven't executed the cell where you define it.
This is evident from the input indicator on the left hand side.
In [ ] -> implies that the code hasn't been executed;
In [*number*] -> implies that the code has been executed and with a consecutive number *some number*
To fix that, simply run the cell with the function and it should work alright!
Kind regards,
Iliya