[ create a new paste ] login | about

Link: http://codepad.org/TYQy8yP7    [ raw code | output | fork | 1 comment ]

Jaqknife - Python, pasted on Jul 14:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def find_max(num_1, num_2):
   max_val = 0.0

   if (num_1 > num_2):  # if num1 is greater than num2,
      max_val = num_1   # then num1 is the maxVal.
   else:                # Otherwise,
      max_val = num_2   # num2 is the maxVal
   return max_val

num_a = 5.0
num_b = 10.0
num_y = 3.0
num_z = 7.0
max_sum = 0.0

max_sum = find_max(num_a,num_b)+find_max(num_y,num_z)

print('max_sum is:', max_sum)


Output:
1
('max_sum is:', 17.0)


Create a new paste based on this one


Comments:
posted by Jaqknife on Jul 14
Assign max_sum with the max of (num_a, num_b) PLUS the max of (num_y, num_z). Use just one statement. Hint: Call find_max() twice in an expression.

reply