To write a program to find the largest of 2 numbers use the if-else statement in Python, You have to compare two numbers using the if-else statement and will print the largest number.
Python program to find largest of 2 numbers example
def maximum(a, b): if a >= b: return a else: return b # Driver code a = 0 b = 7 print("Largest number", maximum(a, b))
Do comment if you have any doubts or suggestions on this Python program.
Note: IDE: PyCharm 2021.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.