234k views
20 votes
Write a program whose inputs are two integers, and whose output is the smallest of the two values.

Ex: If the input is:

Preferred in Python
7

15

the output is:


7

User Don Jose
by
2.9k points

1 Answer

5 votes

Answer:

Step-by-step explanation:

This can easily be done by using the min function, although since it's asking you to write a program to do this I would implement it like this:

def minimum(a, b):

if a < b:

return a

else:

return b

if a is less than b, then of course the minimum value if a. But if it isn't that means one of two things, a=b or b<a, either way b will still be the minimum value, since it never mentioned anything about returning something else if a=b.

User Matthew Moss
by
3.4k points