I'm trying to understand how to get 2 decimal places in this code. Codio is reading it as one. It is not requiring a float command. If I were to enter a float, where would I actually add the $%.2f command in regard to this string. I am very new to coding, so I just want to make sure that I am creating the proper syntax. Been working on this for hours.
if rentalCode == "B":
budgetCharge = 40.00
baseCharge = rentalPeriod * budgetCharge
elif rentalCode == "D":
budgetCharge = 60.00
baseCharge = rentalPeriod * budgetCharge
elif rentalCode == "W":
budgetCharge = 190.00
baseCharge = rentalPeriod * budgetCharge
print(baseCharge)
Defining
budgetCharge
with 2 decimal places will have no use. You can specify how many decimal places by using format strings: