If Statements & Comparisons

Python has six comparison operators, which are as follows :

  • Less than ( < )
  • Less than or equal to ( <= )
  • Greater than ( > )
  • Greater than or equal to ( >= )
  • Equal to ( == )
  • Not equal to ( != )


def max_num(num1, num2, num3):
  if num1 >= num2 and num1 >= num3:
    return num1
  elif num2 >= num1 and num2 >= num3:
    return num2
  else:
    return num3


print(max_num(300, 40, 5))
//Output : 300