Fix Python – How do I find the maximum of 2 numbers?

Question

Asked By – Shilpa

How to find the maximum of 2 numbers?

value = -9999
run = problem.getscore()

I need to compare the 2 values i.e value and run and find the maximum of 2. I need some python function to operate it?

Now we will see solution for issue: How do I find the maximum of 2 numbers?


Answer

Use the builtin function max.

Example:
max(2, 4) returns 4.

Just for giggles, there’s a min as well…should you need it. 😛

This question is answered By – Ashley Grenon

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0