Program to find the largest among 2 numbers, 3 numbers using Python

Hello everyone, welcome to nkcoderz.com. In this article we will going to discuss about Program to find the largest among 2 numbers, 3 numbers using Python.

To find the largest number among two numbers in Python, you can use the following code:

Program to find the largest among 2 numbers

def find_largest(a, b):
  if a > b:
    return a
  else:
    return b

This function takes two numbers as input and returns the larger of the two.

Here’s an example of how you could use this function:

a = 5
b = 10
print(find_largest(a, b))

Output

10

To find the largest number among three numbers, you can use the following code:

Program to find the largest among 3 numbers

def find_largest(a, b, c):
  if a > b and a > c:
    return a
  elif b > a and b > c:
    return b
  else:
    return c

This function takes three numbers as input and returns the largest of the three.

Here’s an example of how you could use this function:

a = 5
b = 10
c = 15
print(find_largest(a, b, c))

Output

15

Program to find the given year is a leap year using Python

Conclusion

If you liked this post, then please share this with your friends and make sure to bookmark this website for more awesome content.


If You Like This Page Then Make Sure To Follow Us on Facebook, G News and Subscribe Our YouTube Channel. We will provide you updates daily.
Shares
facebook sharing button Share
twitter sharing button Tweet
whatsapp sharing button Share
telegram sharing button Share
pinterest sharing button Pin

Leave a Comment