Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97386
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: function code snippet that has function calls I have never seen before. How does it work. |
| Date | 2015-10-03 19:59 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <mupc2b$ct3$1@dont-email.me> (permalink) |
| References | <ae836f80-185b-45ad-81b0-a3644a0e649e@googlegroups.com> |
On Sat, 03 Oct 2015 10:40:57 -0700, Ronald Cosentino wrote:
> def funA(x,y,z):
> return (x+y) * z
> def funB(x,y):
> return(x-y)
> print(funA(4,funB(2,3), funB(3,2)))
>
> the answer is 3. I don't know how it works.
def funA(x, y, z):
return (x+y) * z
def funB(x, y):
return (x-y)
# this line
# print(funA(4,funB(2,3), funB(3,2)))
# can be written as the following 4 lines:
a = funB(2, 3) # 2 - 3 -> -1
b = funB(3, 2) # 3 - 2 -> 1
c = funA(4, a, b) # (4 + -1) * 1 -> 3
print(c) # 3
--
Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
function code snippet that has function calls I have never seen before. How does it work. Ronald Cosentino <ronjc.2001@gmail.com> - 2015-10-03 10:40 -0700 RE: function code snippet that has function calls I have never seen before. How does it work. "Joseph Lee" <joseph.lee22590@gmail.com> - 2015-10-03 11:03 -0700 Re: function code snippet that has function calls I have never seen before. How does it work. Ervin Hegedüs <airween@gmail.com> - 2015-10-03 20:09 +0200 Re: function code snippet that has function calls I have never seen before. How does it work. Denis McMahon <denismfmcmahon@gmail.com> - 2015-10-03 19:59 +0000 Re: function code snippet that has function calls I have never seen before. How does it work. Steven D'Aprano <steve@pearwood.info> - 2015-10-05 00:42 +1100
csiph-web