1. Engineering
  2. Computer Science
  3. using the following solve using python and use the code...

Question: using the following solve using python and use the code...

Question details

using the following solve using python and use the code at bottom of page to run test MUST PAST ALL TESTS

def if_function(condition, true_result, false_result):
"""Return true_result if condition is a true value, and
false_result otherwise.

>>> if_function(True, 2, 3)
2
>>> if_function(False, 2, 3)
3
>>> if_function(3==2, 3+2, 3-2)
1
>>> if_function(3>2, 3+2, 3-2)
5
"""
if condition:
return true_result
else:
return false_result
def with_if_statement():
"""
>>> with_if_statement()
1
"""
if c():
return t()
else:
return f()

def with_if_function():
eturn if_function(c(), t(), f())

def c():
"*** YOUR CODE HERE ***"

def t():
"*** YOUR CODE HERE ***"

def f():
"*** YOUR CODE HERE ***"

def _test():
import doctest
doctest.testmod(verbose=True)

if __name__ == "__main__":
_test()

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution