Question

In: Computer Science

CSC 101 Assignment 3 Barista Assistant Due Date: Friday, October 30 at 11:59 PM Learning Objectives:...

CSC 101 Assignment 3

Barista Assistant

Due Date: Friday, October 30 at 11:59 PM

Learning Objectives: Practice combining your knowledge of conditionals, loops, functions, strings, and lists.

What to Submit: Write your program in a Python script named barista.py. Submit this file to the Assignment 3 page on Canvas.

Description

The purpose of this assignment is to write a Python program for a cafe to help baristas create coffee for a customer. Your program will take the customer's order and produce a set of instructions for the barista to make the coffee.

Your application will need to perform the following:

  • Have the customer enter the type of coffee they want. Options include 'Long Black', 'Flat White', 'Latte', or 'Short Black'.

  • If the customer does not provide one of the above options, your program should return the following error message and ask for input again:
    Please try again.

  • With a correct coffee order that is either a long or short black, have your program ask the customer if they want milk on the side. The customer must answer correctly either with 'Y' or 'N' (for yes or no). If they do not answer correctly, have your program display the following error message and ask for input again:
    Please try again.

  • For any correct coffee order, have your program ask the customer if they would like their order to-go. Like the milk question, this question expects a response of either 'Y' or 'N'. If they do not answer correctly, have your program display the following error message and ask for input again:
    Please try again.

  • When checking the customer's request, your program should ignore character case sensitivity. For example, 'Y' and 'y' are both correct, as well as 'Long Black' and 'long BLACK'.

  • After all the correct answers have been given, have your program print out the customer's coffee request in the following format:

    • Main Coffee Type

    • Milk Extra

    • To-Go Option

  • Create a function pose_question(prompt, acceptable_responses) that performs the questioning operation. The function will check the customer's response based on the acceptable_responses list. This function is responsible for asking the question provided in the prompt parameter and checking to see if the user's response is in the acceptable_responses list.
    Upon a successful response, the function will return the user's input. If not, it will display an error message and continue to loop.
    Hint: Use one of the string methods, .lower() or .upper(), to ignore character case.
    Hint 2: Remember you can use the the in operator to check to see if an item is part of a list.

For full credit, add extra options to the order, such as flavor syrups, other coffee/espresso drink types, etc. Follow a similar format as the other questions for whatever extra options you decide to add, such as checking for valid responses.

Solutions

Expert Solution

Here is the Python code

def pose_question(prompt, acceptable_responses):
    acceptable_responses = [r.lower() for r in acceptable_responses]
    
    while True:
        resp = input (prompt).lower()
        if resp in acceptable_responses:
            return (acceptable_responses.index (resp))
        else:
            print ("Please try again.")
            continue
    

rsp = ['Long Black', 'Flat White', 'Latte', 'Short Black']
yn = ['Y', 'N']
coffeetype = pose_question ("Which coffee type ['Long Black', 'Flat White', 'Latte', or 'Short Black']: ", rsp)   
milk = pose_question ("Do you want milk on the side ['Y', 'N']: ", yn)   
togo = pose_question ("Is your order to-go ['Y', 'N']: ", yn)   
flavor = pose_question ("Do you want to add a flavor syrup ['Y', 'N']: ", yn)   

print ("Main coffee type: ", end = " ")
print (rsp [coffeetype])
print ("Milk extra: ", end = " ")
print (yn [milk])
print ("To-go option: ", end = " ")
print (yn [togo])
print ("Flavor syrup: ", end = " ")
print (yn [flavor])



Related Solutions

A Sweaty Weight Lifter Due this Friday, Dec 4 at 11:59 pm (EST) In exercising, a...
A Sweaty Weight Lifter Due this Friday, Dec 4 at 11:59 pm (EST) In exercising, a weight lifter loses 0.142 kg of water through evaporation, the heat required to evaporate the water coming from the weight lifter's body. The work done in lifting weights is 1.38E+5 J. Assuming that the latent heat of vaporization of perspiration is 2.45E+6 J/kg, find the change in the internal energy of the weight lifter.
This assignment is worth 4.0% of your final grade and is due by Thursday, 11:59 PM...
This assignment is worth 4.0% of your final grade and is due by Thursday, 11:59 PM ET of week 7. Instructions There are many tools available to assist you as an RN to organize your thoughts, make nursing judgments, and implement the 5 rights of delegation. SBAR – Situation, Background, Assessment, and Recommendation, is a standardized tool used in many institutions that provides a framework to facilitate clear communication between health care providers. The components of SBAR are as follows,...
Ice to Steam via Water Due this Friday, Dec 4 at 11:59 pm (EST) How much...
Ice to Steam via Water Due this Friday, Dec 4 at 11:59 pm (EST) How much heat is required to change a 49.4 g ice cube from ice at -13.7°C to water at 50°C? (if necessary, use cice=2090 J/kg°C and csteam= 2010 J/kg°C) 2.82×104 J You are correct. Your receipt no. is 150-2609 Help: Receipt Previous Tries How much heat is required to change a 49.4 g ice cube from ice at -13.7°C to steam at 120°C?
Due Sunday, November 1st at 11:59 PM Deliverables There is one deliverable for this assignment hw7.py...
Due Sunday, November 1st at 11:59 PM Deliverables There is one deliverable for this assignment hw7.py Make sure the script obeys all the rules in the Script Requirements page. Specification Your script must print a Kelvin to Fahrenheit conversion table and between a minimum and maximum values, and a Fahrenheit to Kelvin conversion also between a minimum and maximum values. Here is the formula for converting Kelvin to Fahrenheit Here is the formula for converting Fahrenheit to Kelvin The script...
Econ 335: Assignment 4 Due: April 20th by 11:59 PM 1.     To protect American jobs, the...
Econ 335: Assignment 4 Due: April 20th by 11:59 PM 1.     To protect American jobs, the US government may decide to cut US imports of bulldozers by 60%. It could do so by either: -Imposing a tariff high enough to cut bulldozer imports by 60% -Persuading Komatsu and other foreign bulldozer makers to set up a voluntary export restraint arrangement to cut their exports of bulldozers to the US by 60%. a. Which of these two policies would be less...
CSC 225 Discrete Structures for Computer Science Home Work 3 Due Date: March 31, 2017 Friday...
CSC 225 Discrete Structures for Computer Science Home Work 3 Due Date: March 31, 2017 Friday 2:00pm. 1. Write what is Reflective relation and give an example 2. What are the different types of relations discussed in class write with examples 3. Let A = {0, 1, 2, 3, 4} and B = {a, b, c, d}. Then {(0, a), (0, b), (1, a), (2, b), (3, c), (4, d)}} is a relation from A to B. Represent the above...
PSY 2030-Assignment 3:Chi-Square Tests Due by Sunday, April 12th, at 11:30 PM Scores out of 25...
PSY 2030-Assignment 3:Chi-Square Tests Due by Sunday, April 12th, at 11:30 PM Scores out of 25 points (13 points for Question 1 and 12 points for Question 2) Submit by uploading file(s) within "Assignment 3" on Canvas SHOW YOUR WORK!! Either very clearly type it out (making sure your formulas and integrity/formatting of your formulas are extremely clear) Or write it out by hand and attach a scan or photo of your work Remember that all assignments must reflect your...
PSY 2030 -Assignment 4: One-Way Anova -Due by Sunday, April 19th, at 11:30 PM -Scores out...
PSY 2030 -Assignment 4: One-Way Anova -Due by Sunday, April 19th, at 11:30 PM -Scores out of 25 points (16 points for Question and 9 points for Question 2) -Submit by uploading file(s) within "Assignment 4" on Canvas -SHOW ALL WORK!! Either very clearly type it (making sure your formulas and integrity/formatting of formulas are extremely clear) or write it out by hand and attach a scan or photo of your work. Remember that all assignments must reflect your own...
HOMEWORK ASSIGNMENT # 1 Due Date: Tuesday, February 20, 2018 by 5:15 pm Required format: This...
HOMEWORK ASSIGNMENT # 1 Due Date: Tuesday, February 20, 2018 by 5:15 pm Required format: This assignment is worth 20 pts. You should use Microsoft Word or a similar typing program to write your answers to the questions below. Hand-written copies will be subject to a deduction of 5 pts. Take a photo of your graphs and paste them as a picture in your document or draw them using one of the drawing tools available in Excel or Word. All...
CSCE 3600: Systems Programming Recitation Assignment 4 – Bash script Due: 06:00 PM on Monday October...
CSCE 3600: Systems Programming Recitation Assignment 4 – Bash script Due: 06:00 PM on Monday October 12 2020 DESCRIPTION: You need to write a bash script to compile and execute a C program. Please feel free to ask for assistance from your TA or fellow classmates, but make sure that you turn in your own work. Please note that you are writing bash scripts, not C programs, for this exercise. Write a bash script that accepts a C file name...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT