This is the presentation associated with the python number formatting video.
[dflip id=”3419″ ][/dflip]
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}")
[bg_collapse view=”button-blue” color=”#ffffff” icon=”eye” expand_text=”Show Answer” collapse_text=”Hide Answer” ]
In [1]:
price = 75365.23
discount = 0.05
print(f"Price : ${price:,.3f}")
print(f"discount : {discount:.3%}")
[/bg_collapse]