In: Computer Science
#######################################################################################################
######################################################################################
###########################################################
#############################using python###################
###########################################################
# RQ1
from operator import add, sub
def a_plus_abs_b(a, b):
"""Return a+abs(b), but without calling abs.
>>> a_plus_abs_b(2, 3)
5
>>> a_plus_abs_b(2, -3)
5
"""
if b < 0:
f = _____
else:
f = _____
return f(a, b)
# RQ2
def two_of_three(a, b, c):
"""Return x*x + y*y, where x and y are the two largest members of the
positive numbers a, b, and c.
>>> two_of_three(1, 2, 3)
13
>>> two_of_three(5, 3, 1)
34
>>> two_of_three(10, 2, 8)
164
>>> two_of_three(5, 5, 5)
50
"""
return _____
RQ 1)
# Defining the function
def a_plus_abs_b(a , b):
if(b >= 0):
return a + b
else :
return a - b
# Testing the function
print(a_plus_abs_b(2 , 3))
print(a_plus_abs_b(2 , -3))

OUTPUT:
RQ2)
# Defining the function
def two_of_three(a , b , c):
if(a <= b and a <= c):
return b**2 + c**2
elif (b <= a and b <= c):
return a**2 + c**2
else :
return a**2 + b**2
# Testing the function
print(two_of_three(1 , 2 , 3))
print(two_of_three(5 , 3 , 1))
print(two_of_three(10 , 2 , 8))
print(two_of_three(5 , 5 , 5))

OUTPUT:
