Question

In Python, Prompt the user to enter their current budget and the number of people who...

In Python, Prompt the user to enter their current budget and the number of people who need to share a meal. You are entering food from a restaurant that has two menu options. Tacos $4, Epandas $3.

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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")

Add a comment
Know the answer?
Add Answer to:
In Python, Prompt the user to enter their current budget and the number of people who...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Python please. At Jenny’s birthday party she orders a 32-piece pizza. Have the user enter...

    In Python please. At Jenny’s birthday party she orders a 32-piece pizza. Have the user enter the number of people at the party that will be eating pizza and output the number of slices each one gets. As you know the pizza might not divide evenly. There are two ways to handle this. The first is to ignore the extra pieces and give everyone the same amount. The second way is to cut up the extra pieces so that everyone...

  • I am struggling with a program in C++. it involves using a struct and a class...

    I am struggling with a program in C++. it involves using a struct and a class to create meal arrays from a user. I've written my main okay. but the functions in the class are giving me issues with constructors deconstructors. Instructions A restaurant in the Milky way galaxy called “Green Alien” has several meals available on their electronic menu. For each food item in each meal, the menu lists the calories per gram and the number of grams per...

  • Are the following random variables binomial? If it is, state the possible values of the random variable. If not, state w...

    Are the following random variables binomial? If it is, state the possible values of the random variable. If not, state why. (Hint: Check the five characteristics of a binomial experiment that we discussed in class.) (a) Bob is teaching his daughter Tina to drive. They have one driving lesson a day for one week. X = the number of days that Tina successfully goes without hitting another car. (b) Joey and Chandler are playing a board game that involves rolling...

  • C++ (1) Prompt the user to enter a string of their choosing (Hint: you will need...

    C++ (1) Prompt the user to enter a string of their choosing (Hint: you will need to call the getline() function to read a string consisting of white spaces.) Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!...

  • Read Case Study 1: Gormand and Food—A Fable in Chapter 1 of your textbook. Identify the...

    Read Case Study 1: Gormand and Food—A Fable in Chapter 1 of your textbook. Identify the commonalities between this case study and the delivery of healthcare in the United States. What in this case study is not likely to occur to healthcare in the United States? Why? Gourmand and Food—A Fable225 The people of Gourmand loved good food. They ate in good restaurants, donated money for cooking research, and instructed their government to safeguard all matters having to do with...

  • Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create...

    Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create a completed program that prompts the user for the name of a data file, and reads the contents of that data file, then creates variables in a form suitable for computing the answer to some questions. The format should be in the same manner as the attached .py file. All subsequent assignment details (.py and .csv files) can be found at this...

  • write by python code and screenshoot the python code for me. thanks The Problem: You are...

    write by python code and screenshoot the python code for me. thanks The Problem: You are to design a Calorie Intake Assistant tailored to the user’s personal characteristics. The assistant will initially ask the user for his/her gender, name, age in years, height in cm and weight in kg. Based on these, the assistant will calculate the recommended daily calorie intake (RDCI) using the Mifflin – St Jeor formula[1], which is also shown to the user: Mifflin – St Jeor...

  • Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming...

    Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming skills that you learn in Murach’s Python Programming to develop a program that helps a person manage a baseball team. This program stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. After you read chapter 2, you can develop a simple program that calculates the batting average for a player. Then,...

  • In Java The fancy new French restaurant La Food is very popular for its authentic cuisine...

    In Java The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of their operations, the Maitre De has hired you to write a program that simulates people waiting for tables. The goal is to determine the average amount of time people spend waiting for tables. Your program will read in a list of event descriptions from a text file, one description...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT