Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Wednesday, May 8, 2013

Min and Max of 2 numbers


Problem: Find minimum and maximum of given 2 numbers.

Solution in Python:

def max(n, m):
    """
    Author: Mayur P Srivastava
    """

    if n >= m:
        return n
    return m

def min(n, m):
    """
    Author: Mayur P Srivastava
    """

    if n < m:
        return n
    return m


Concepts Learned: Logical conditions.

No comments:

Post a Comment