# Maximum of two numbers in Python

Given two numbers, write a Python code to find the Maximum of these two numbers.

Examples:

```Input: a = 2, b = 4
Output: 4

Input: a = -1, b = -4
Output: -1
```

Method #1: This is the naive approach where we will compare tow numbers using if-else statement and will print the output accordingly.

Example:

 `# Python program to find the ` `# maximum of two numbers ` ` `  ` `  `def` `maximum(a, b): ` `     `  `    ``if` `a >``=` `b: ` `        ``return` `a ` `    ``else``: ` `        ``return` `b ` `     `  `# Driver code ` `a ``=` `2` `b ``=` `4` `print``(maximum(a, b)) `

Output:

`4`

Method #2: Using max() function

This function is used to find the maximum of the values passed as its arguments.

Example:

 `# Python program to find the ` `# maximum of two numbers ` ` `  ` `  `a ``=` `2` `b ``=` `4` ` `  `maximum ``=` `max``(a, b) ` `print``(maximum) `

Output:

`4`
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.