mardi 22 janvier 2019

Define a function to choose 2 bigger number out of 3 numbers then sum the square of the 2 numbers

Define a function that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.

For example, given 6,7,8, the function that I defined should return 113

When I gave my code, it solves most of the problems but apparently there is some possibility that I haven't tried?? I think my code is flawed but not sure what other possibilities are there. Would really appreciate some help thank you so much!

def bigger_sum(a,b,c):
      if(a+b>b+c):
          return(a*a+b*b)
      if(a+c>b+c):
          return(a*a+c*c)
      if(b+c>a+c):
          return(b*b+c*c)

Aucun commentaire:

Enregistrer un commentaire