For example, suppose that one serving of Sambar takes 500 g of tomato and 300 g of onion. Suppose that you have a 900 g package of tomato and a 660 g package of onion. You could form these into a kit that makes two servings of Sambar. To make two servings, 1000 g of tomato and 600 g of onion are required. Since the 900 g of tomato you have is within [90, 110]% of the 1000 g of tomato required, and the 660 g of onion you have is within [90, 110]% of the 600 g of onion required, this is acceptable. However, you could not say that the kit makes one or three servings of Sambar, nor could you say that it makes 1.999 servings (the number of servings must be an integer).
import math
tomatoes = int(input('grams of tomato :'))
onion = int(input('grams of onion :'))
rquaired_tomato = 500
required_onion = 300
a = tomatoes / rquaired_tomato
b = onion / required_onion
a,b= math.ceil(a),math.ceil(b)
min_int = min(a,b)
if tomatoes < 400 or onion < 400:
print('not enought of onion or tomatoes!')
else:
print(min_int)
Comments
Leave a comment