Sal's shipping objective in python 3(Control Flow): I am getting the results I want, but it comes with weird numbers printed ...help!

Link to my code:
Sal’s Shipping Objective (Control Flow Section)

This is my first post, so if I’m not following the desired style, I would like to apologize ahead of time.
It would be appreciated if you inform me how I could improve my posts too!

So, my Sal’s shipping code works decently, printing results that I was hoping to see, but it comes with weird numbers as well.

I have found out that the weird numbers were printing whenever I execute a function that compares the price of the shipping fees and tells the user which option of shipping would be the best fit for them.

Compare function:

def compare(weight):
  choice = ""
  gs = Ground_Shipping(weight)
  ds = Drone_Shipping(weight)
  ps = 125

  if gs > ds and ps > ds:
    choice = "The cheapest option for your package is Drone Shipping which will be " + str(ds) + " USD."

  elif ds > gs and ps > gs:
    choice = "The cheapest option for your package is Ground Shipping which will be " + str(gs) +" USD."

  else:
    choice = "The cheapest option for your package is Premium Shipping which will be " + str(ps) +" USD."
    
  print(choice)

If I plug in 4.8 in weight, the result comes out as:

34.4
43.199999999999996
The cheapest option for your package is Ground Shipping which will be 34.4 USD.

I am not sure where 34.4 and 43.199… are coming from…

:…(

Welcome to the forums @junghopark8564582995 !

Take a look at the code inside your Ground_Shipping and Drone_Shipping functions. You’re actually printing out cost and costd, respectively, in those functions.

2 Likes

We should mention that using Capitalization goes against the norms of the coding community. Capital first letters are generally reserved for class names. Get used to using lower case so as to fit into the scheme.

2 Likes

Oh wow…how did I not notice that? Thank you for the correction!

1 Like

I will keep that in mind from now. Thank you for the great tip!

1 Like