I want to do a story problem on the following math.
A merchant sells an item at a price $210.00 and profit 5% of the price buy. Determine the purchase price the item.
The answer is like the following
.
Then, I solved it with the code below.
from fractions import Fraction
def purchase_price(pp, profit):
x = pp + profit
return x
pp = 100
profit = 5
a = pp + profit
a = 210 * Fraction(100, 105)
print('${:,.2f}'.format(a))
the result is like this.
TypeError: unsupported format string passed to Fraction.__format__
And I, who is still a beginner, want to ask... does my code look neat and clean?
My study materials are here and here.
Thank you, any help will be highly appreciated.
Just use python's normal fraction
100/105Your code should look like this