Write two functions, one called addit and one called mult. addit takes one number as an input and adds 5. mult takes one number as an input, and multiplies that input by whatever is returned by addit
using output of one function into another function
using output of one function into another function
|
Jun-24-2019, 05:14 AM
Thank you for sharing your task, the forum can assist you on parts your are stuck with but cannot do your task for you.
When you get stuck, please post a minimal code sample (in python code tags) for the specific part your stuck on, explain what you expect to happen and what is actually happening and any errors received in error tags. If someone can they will then assist you.
Jun-24-2019, 05:16 AM
Where´s your code? What´ve you tried so far?
sorry for asking this direct question
i tried the given code but get an namerror' Error: NameError: name 'num' is not defined, def addit(num): return num+5 def mult(b): y=b*addit(num) return y
Jun-24-2019, 06:10 AM
You should think along those lines:
>>> def my_int(num): ... return int(num) ... >>> def my_calc(num): ... return num ** num + num ... >>> my_calc(my_int('5')) 3130
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Jun-24-2019, 06:11 AM
Hi,
that's correct, line 5 gives a NameError, as num is unknow there. The key word is: scoping. num is simply unknown in the local scope of mult . If you need num within the funciton, pass it as an argument.Regards, noisefloor
Jun-24-2019, 06:16 AM
@noise floor
can you please correct my code
Jun-24-2019, 08:43 AM
Hi,
@ibaad1406: actually I could, but I don't. This is not a "fullfil my wish" forum. We can guide you to the solution, but YOU have to work out the solutions yourself. Otherwise, you won't learn anything. I gave you the solution already in my previous post, you just have to cast it into code. In case it doesn't work, show your new code, describe your problem, and you will get further assistance. Regards, noisefloor |
|
Users browsing this thread: 1 Guest(s)