Python Number Formatting Presentation


This is the presentation associated with the python number formatting video.

Download Presentation

Python Number Formatting Video Question

This is the question that was asked in the python number formatting video

Question : 

Modify the below f-string to print price and discount as per the required output.

Required output:
	Price : $75,365.230
	discount : 5.000%
In [1]:
price = 75365.23
discount = 0.05
print(f"Price : ${price}")
print(f"discount : {discount}")
Price : $75365.23
discount : 0.05
In [1]:
price = 75365.23
discount = 0.05
print(f"Price : ${price:,.3f}")
print(f"discount : {discount:.3%}")
Price : $75,365.230
discount : 5.000%