Question on Python Function

joy99 subhakolkata1234 at gmail.com
Thu May 27 16:50:29 EDT 2010


On May 25, 12:18 pm, Peter Otten <__pete... at web.de> wrote:
> Kushal Kumaran wrote:
> > On Tue, May 25, 2010 at 3:38 AM,joy99<subhakolkata1... at gmail.com> wrote:
> >> <snip>
>
> >> Dear Vlastimir,
>
> >> As pointed out by Alister, I can print the values of function1 and
> >> function2 with the help of another function3, but my target is to call
> >> the "add" value of function1 and "mult" value of function2 in a third
> >> function or the values and parameters of the third function in fourth
> >> function. While calling, I am looking not only to print, but to use
> >> them or manipulate them.
>
> >> I hope I am bit clear now.
>
> > If you need to use the values in another function, you need a way to
> > let that function get its hands on the values.  Your function1 and
> > function2 should return the values they compute instead of printing
> > them out.
>
> For example:
>
>  >>> def add(x, y):
> ...     return x + y
> ...>>> def mul(x, y):
>
> ...     return x * y
> ...>>> def sum_of_squares(x, y):
>
> ...     return add(mul(x, x), mul(y, y))
> ...>>> sum_of_squares(3, 4)
>
> 25
>
> OP: If that addresses your question I suggest that you work through some
> introductory text about python. The python wiki has a few suggestions, see
>
> http://wiki.python.org/moin/BeginnersGuide
>
> Peter

Hi Peter and Other Kind Contributors of the Group,

I got lot of insights from the discussion in the group. Though I did
not get the exact answer but from Peter's link I could work them out.
Thank you, Peter, for kindly referring me the link. I like to thank
others of the group also for kindly spending their valuable time. I
wanted to define one function and call the value of that function to
be used by another function. If I misquoted the problem, I am sorry.

Wishing You all a Great Day Ahead,
Best Regards,
Subhabrata.



More information about the Python-list mailing list