Write some Python code that defines a function called find_min(a,b) that returns the

smallest of the two given parameter values? Can some one help me with this please?

Thank you so much megha

```
def find_min(a, b):
return a if a < b else b
```

We can use this as well (compress python code)

@NicolasATC, in case of equal numbers, itâ€™d go for the else case and returns b, since both are equal doesnâ€™t matter which one do we return.

@farhan787, that totally depends on the problem you are trying to solve. So, analyzing the problem will dictate if you have to identify if 2 numbers are the same.

As I read on this quote:

## A Good Programmer Is Someone Who Looks Both Ways Before Crossing A One-way Street.

â€“ Doug Linde

def find_max(a, b):

if a == b:

return f"{a} is equal to {b}"

elif return a > b ? a : b

You get the point, the indentation isnâ€™t coming out

@NicolasATC nice quote but nothing depends on the problem here, we simply have to return the minimum number, why to complicate this thing? Also, my function is handling all the cases assuming the parameters passed are numbers because I didnâ€™t do any validation there.

If the function looks for the minimum between 2 numbers, then thatâ€™s what it should return. If you pass 5 and 5, and your code returns 5 as the smallest, then your code is not giving back the correct output, because 5 is not smaller than 5. In this case the 2 numbers are equal, so

But in the end it is your code, I was just trying to provide another point of view to your code. Some people accept it, some donâ€™t.

All the best in your coding journey!

@farhan787â€™s function is the only function posted here that fulfills the requirement of returning one of the given parameter values.

If you pass 5 and 5 to a function what is the smallest value passed to that function? Well, itâ€™s 5.

Since the text is a common programming excercise with a common function name we can assume that we should implement a Min()-function as seen in almost all standard libraries that behave exactly like this and returns the *minimum* of the given arguments.

Use code fences.

I am just a beginner here but i like @farhan787â€™s function better. In the end of the day, there is really no right or wrong function as long as you get the desired result. You shouldnâ€™t care what happens under the hood of a function if you just want which number is the smaller from the two. When you call the print() function you donâ€™t look under the hood and say well i donâ€™t like the way they wrote it so it doesnâ€™t meet my requirements.

From what i read and learned, if youâ€™re writing a lot of repetitive wordings in your function, there is a better way to write it.

farhan is showing more of a more efficient and cleaner code.

The function name is find_min() and if you wanted to define what your function does it is to find the minimum of two numbers and he minimum of 5 and 5 is 5 right? if you wanted to find if numbers are equal then right a new function find_equal_num() or something.

just my 2 centsâ€¦

Thanks @SAM and edu for getting what Iâ€™ve done. @NicolasATC donâ€™t take me wrong but I guess youâ€™ve just started with programming, if you donâ€™t believe me or my code then you can try `min(5,5)`

in Python and `Math.min(5,5)`

in JavaScript and `std::min(5,5)`

in C++. All will return 5, because thatâ€™s the right answer. Agreed that 5 < 5 is not true but in context of minimum number the answer would be 5.