def receive_fees():
bread = None
ice_cream = None
while bread is None or ice_cream is None:
if bread is None:
try:
bread = int(input('Enter the cost of bread :'))
if type(bread) == int or type(bread) == float :
bread = bread
except (TypeError ,ValueError):
print('You did not enter the information correctly')
bread = None
continue
if ice_cream is None:
try:
ice_cream = int(input('Enter the cost of ice cream :'))
if type(ice_cream) == int or type(ice_cream) == float:
ice_cream = ice_cream
except (TypeError ,ValueError):
print('You did not enter the information correctly')
ice_cream = None
continue
if bread != None and ice_cream != None:
return bread ,ice_cream
bread , ice_cream = receive_fees()
def sales_profit(bread ,ice_cream ,price ,number_of_sales):
costs = bread + ice_cream
income = price * number_of_sales
profit = income - costs
print(profit)
def amount_of_sales_and_income():
price = None
number_of_sales = None
while price is None or number_of_sales is None:
if price is None:
try:
price = int(input('Enter the price of each ice cream :'))
if type(price) == int or type(price) == float :
price = price
except (TypeError ,ValueError):
print('You did not enter the information correctly')
price = None
continue
if number_of_sales is None:
try:
number_of_sales = int(input('Enter the number of ice creams sold :'))
if type(number_of_sales) == int or type(number_of_sales) == float:
number_of_sales = number_of_sales
except (TypeError ,ValueError):
print('You did not enter the information correctly')
number_of_sales = None
continue
if price != None and number_of_sales != None:
sales_profit(bread ,ice_cream ,price ,number_of_sales)
amount_of_sales_and_income()