206k views
0 votes
Min/Max Templates Write templates for the two functions min and max. min should accept two arguments and return the value of the argument that is the lesser of the two. max should accept two arguments and return the value of the argument that is the greater of the two. Design a simple driver program that demonstrates the templates with various data types.

User YRUsoDiao
by
7.9k points

1 Answer

4 votes

Answer:

x = int(input('Enter First value'))

y = int(input('Enter Second value'))

def minimum(x,y):

diff = min(x,y)

print('The minimum value is ' + str(diff))

def maximum(x,y):

diff = max(x,y)

print('The maximum value is ' + str(diff))

func_dict = {'maximum':maximum, 'minimum': minimum}

if __name__ == "__main__":

command = input("> ")

func_dict[command](x,y)

Step-by-step explanation:

Asked user to input two values.

and than ask the user to select either to find maximum value or minimum value.

When user will type maximum or minimum the same function will be called and print the answer

User Wemu
by
9.1k points