We need to write some code to return the original price of a product, the return type must be of type decimal and the number must be rounded to two decimal places.

We will be given the sale price (discounted price), and the sale percentage, our job is to figure out the original price.


### For example:

Given an item at $75 sale price after applying a 25% discount, the function should return the original price of that item before applying the sale percentage, which is ($100.00) of course, rounded to two decimal places.


DiscoverOriginalPrice(75, 25) => 100.00M where 75 is the sale price (discounted price), 25 is the sale percentage and 100 is the original price

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code: def discover_original_price(discounted_price, sale_percentage):
	

Solutions:
def discover_original_price(discounted_price, sale_percentage):
	return round(discounted_price / ((100 - sale_percentage) * 0.01), 2)


def discover_original_price(discounted_price, sale_percentage):
	return round(discounted_price / (1 - sale_percentage / 100.0), 2)


discover_original_price = lambda p, d: round(p * 100 / (100 - d), 2)


def discover_original_price(n, p):
	return round(n * 100 / (100 - p), 2)


def discover_original_price(discounted_price, sale_percentage):
	return float('{0: .2f}'.format(discounted_price / (100 - sale_percentage) * 100))


def discover_original_price(discounted_price, sale_percentage):
	if sale_percentage < 100:
		return round(discounted_price * 100 / (100 - sale_percentage), 2)


def discover_original_price(price, perc):
	return float('{:0.2f}'.format(price / (1 - perc / 100)))