How To Get The Maximum Of Two Numbers Using Python?

Noor Fakhry
Sep 14, 2022

--

In This Story I’ll show you how to get the maximum between 2 numbers using python in 5 different ways.

Suppose we have 2 variables x & y, x is equal to 5 and y is equal to 10

Method #1 using if-else statement:

Output = 10

Method #2 using the built-in max() function:

Output = 10

Method #3 using Ternary operator:

Output = 10

Method #4 Using lambda function:

Output = 10 is the max number

Method #5 Using list comprehension:

Output = 10

Conclusion:

In python, there are always many ways to do a specific task, and this is why python is so popular.

Check out my YouTube channel.

--

--

Noor Fakhry
Noor Fakhry

Written by Noor Fakhry

0 Followers

Creator @Youtube | Instructor @Udemy | Software Engineer | Masters in CS | Youtube Channel => https://bit.ly/3d7ZP5j