Sals Shipping Project: How do I round to nearest hundredth?

In this project, https://www.codecademy.com/courses/learn-python-3/projects/python-sals-shipping, I am using round() function on cost variables so I can round them 2 decimal places. The
Built-in Functions — Python 3.9.7 documentation syntax is round ( number [, ndigits ])

weight = 4.8
# Ground shipping
if weight <= 2:
  ground_cost = round(weight * 1.50 + 20.00, 2)
elif weight > 2 and weight <=6:
  ground_cost = round(weight * 3.00 + 20.00, 2)
elif weight > 6 and weight <= 10:
  ground_cost = round(weight * 4.00 + 20.00, 2)
else:
  ground_cost = round(weight * 4.75 + 20.00, 2)

# Ground shipping premium
ground_cost_premium = 125.00
#print('Ground cost premium:',ground_cost_premium)

# Drone shipping
if weight <= 2:
  drone_cost = round(weight * 4.50, 2)
elif weight > 2 and weight <=6:
  drone_cost = round(weight * 9.00, 2)
elif weight > 6 and weight <= 10:
  drone_cost = round(weight * 12.00, 2)
else:
  drone_cost = round(weight * 14.25, 2)


print("Ground Shipping:","$", ground_cost)
print("Ground Shipping Premium:","$", ground_cost_premium)
print("Drone Shipping:","$", drone_cost)
print("")
if ground_cost < drone_cost and ground_cost < ground_cost_premium:
  print("Ground Shipping is your cheapest option.")
elif drone_cost < ground_cost and drone_cost < ground_cost_premium:
  print("Shipping by Drone is your cheapest option.")
else:
  print("Premium Ground Shipping is your cheapest option.")

I am expecting this code to round my print statements to the hundredths place, but instead it is rounded to the tenths.

Ground Shipping: $ 34.4
Ground Shipping Premium: $ 125.0
Drone Shipping: $ 43.2

Ground Shipping is your cheapest option.

Can someone help with my syntax please?

although round worked for me,
I found some string formatting stuff online:

to have the stuff show up to 2 decimal places on the screen (even if it actually has less than 2 decimal places):

print("{:.2f}".format(stuff))
print(round(3.14159, 2)) print(round(3.2, 2)) print(round(6, 2)) print('\n') print("{:.2f}".format(3.14159)) print("{:.2f}".format(3.2)) print("{:.2f}".format(6))
1 Like