93.0k views
2 votes
Write a function called min that returns the minimum of the two numbers passed in as parameters.

Note: Be sure to include comments for all functions that you use or create.

For example, if you made a call like

x = min(10, 14)
x should have the value 10.

For your program, you need to define the function and call it and print out the result like this:

x = min(10, 14)
print("The min is " + str(x))

min(1,2);
min(9000,9001);

it is in python

User Roshdy
by
8.1k points

1 Answer

1 vote

def min(x,y):

smallest = x

if y < smallest:

smallest = y

return smallest

x = min(2,1)

print("The min is "+str(x))

Although I wouldn't recommend using the name min for a function because min is the name of an existing function. Best of luck.

User Vmanjz
by
7.7k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.