Unclear on what this means

python

#1


I'm curiout as to what the ${:.2f}.'. does in this code. Can anyone explain this


#the cost of the server / hour

cost_per_hour = 0.51

#the cost of the server / day

cost_per_day = cost_per_hour * 24

new_cost = cost_per_day

#the cost of the server / month

cost_per_month = cost_per_day * 30

newnew_cost = cost_per_month

print('Cost to operate the server per day is ${:.2f}.'.format(cost_per_day))
print('Cost to operate the server per month is ${:.2f}.'.format(cost_per_month))


#2

This is Python 3 code, which is not covered here in old tracks. Is this from a newer lesson you are working on? If so, please post a link.

{:.2f}  =>  placeholder for float with 2 decimal places (rounded by 4/5 rule)

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.