Created
December 5, 2019 01:26
-
-
Save FerdinaKusumah/fc91cf8efac0508aaa2beba21a8d6a54 to your computer and use it in GitHub Desktop.
Chaining function call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Chain function call""" | |
def sum_product(a, b): | |
return a + b | |
def reduce_product(a, b): | |
return a - b | |
need_to_sum = True | |
a = 10 | |
b = 4 | |
c = (sum_product if need_to_sum is True else reduce_product)(a, b) | |
print(c) | |
# 14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment