Assign max_sum with the greater of num_a and num_b, PLUS the greater of num_y and num_z. Use just one statement. Hint: Call find_max() twice in an expression. Sample output with inputs: 5.0 10.0 3.0 7.0 max_sum is: 17.0

Respuesta :

Answer:

def find_max(num_1, num_2):

   max_val = 0.0

   if(num_1 > num_2):

       max_val = num_1

   else:

       max_val = num_2

   return max_val

max_sum = 0.0

num_a = float(input())

num_b = float(input())

num_y = float(input())

num_z = float(input())

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

print('max_sum is:',max_sum)

Explanation:

fichoh

def find_max(num_a, num_b) :

# define a function named find_max

max_num = 0.0

# initialize maximum number, max_num to 0

if num_a > num_b :

#checks if num_a is greater than num_b

max_num = num_a

#if condition is true, set num_a as max_num

else :

max_num = num_b

#if otherwise, set num_b as max_num

Get user inputs :

num_a = eval(input())

num_b = eval(input())

num_c = eval(input())

num_d = eval(input())

#num_a, num_b, num_c and num_d takes input from user.

max_sum = find_max(num_a, num_b) + find_max(num_c, num_d)

#call the find_max function twice passing the input values as argument

print("max_sum is:", max_sum)

#Display the value of max_sum

Program written in python(3) :

We defined a function find_max to obtain the greater value of any two numbers

  • Using the find_max function, we take 4 user inputs.
  • Then we use the find_max function on the inputs, taking 2 inputs at a time.
  • Then we use the addition operator to take the sum of each maximum output.

Learn more : https://brainly.com/question/14634674

ACCESS MORE