vendredi 10 septembre 2021

Returning the number which has the highest square

I am trying to write a code to return the number which has the highest square. What is wrong in this?

def max_sq(num1, num2, num3, num4):
    if (num1)^2 >= (num2)^2 and (num1)^2 >= (num3)^2 and (num1^2) >= (num4)^2:
        return num1
    elif (num2)^2 >= (num1)^2 and (num2)^2 >= (num3)^2 and (num2)^2 >= (num4)^2:
        return num2
    elif (num3)^2 >=(num1)^2 and (num3)^2 >= (num2)^2 and (num3)^2 >= (num4)^2:
        return num3
    else:
        return num4

print(max_sq(3, 11, 7, 9))

Aucun commentaire:

Enregistrer un commentaire