Ask Question

python program Calculate and print out all the options of meals where the budget is used entirely (where possible) and each person has an equal number of items to eat. They may eat different things, but everyone gets the same number of food items, e. g. 2 tacos or 1 empanada and 1 taco or 2 empanadas.

+3
Answers (1)
  1. 5 April, 03:12
    0
    Python code is explained below

    Explanation:

    We calculated maximum number of tacos and maximum number of espandas individually could be ordered in the provided budget which was round down cause no one can order meal in decimals.

    In first loop, number of tacos was increasing until it reach the maximum number that can be order in that budget.

    In second loop, number of espandas was increasing till it reach the maximum number that can be order, after that total costing was calculated with every possible way the item could be ordered and if the cost of that combination of number of tacos and espandas was equal to the provided budget then number of items ordered can be equally divided among the number of people was checked. When all the conditions were satisfied for the particular combination of meal then the combination was printed.

    CODE:

    import math

    budget = eval (input ("Enter budget:"))

    numberOfPeople = eval (input ("Enter number of people:"))

    nT = math. floor (budget/4) #maximum number of tacos in the budget

    nE = math. floor (budget/3) #maximum number of espandas in the budget

    for T in range (0, nT):

    for E in range (0, nE):

    foodPrice = 4*T + 3*E #money cost for that meal

    if foodPrice = = budget:

    TotalFood = T + E #total number of meal

    if TotalFood % numberOfPeople = = 0:

    print (T,"number of Tacos", end = ' and ')

    print (E,"number of Espandas")
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “python program Calculate and print out all the options of meals where the budget is used entirely (where possible) and each person has an ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers