Question

In: Computer Science

Python Programming- 9.10 MT Practice Simple Food Receipt 2B """ Enhance your simple food receipt a....

Python Programming- 9.10 MT Practice Simple Food Receipt 2B

"""
Enhance your simple food receipt
a. Ask the user for inputs about two food items using the following prompts in turn [add a space after each
question mark]. Do not forget to assign each user
entry to a unique variable name (do not display the Note to add a space just use print() to add a space between each
set of input statements):
Item 1? [add a space after the question mark]
Item 1 price? [add a space after the question mark]
Item 1 number? [add a space after the question mark]
[Note: add space here using print()]
Item 2? [add a space after the question mark]
Item 2 price? [add a space after the question mark]
Item 2 number? [add a space after the question mark]
[Note: add space here using print()]
Item 3? [add a space after the question mark]
Item 3 price? [add a space after the question mark]
Item 3 number? [add a space after the question mark]
[Note: add space here using print()]
b. Convert the price and quantity variables to integers
c. Calculate the total cost for the order by calculating each item's total price by
multiplying price and quantity for each item and then adding up the total prices for the three items
d. Calculate the total cost plus tax for the order by multiplying the total cose calculated in c by the tax
rate of .0545 (5.45 percent tax) then adding the tax to the total cost
e. Display the results using the structure below. Edit the format string "${:,.2f}".format(identfier) to format the
results of your calculation as currency with the PHP currency type, a space between PHP and the calculated costs,
and 1 decimal place:
RECEIPT
You ordered: [Item 1] [Item 2] [Item 3]
Your cost: [total price for all items calculated in 3c above, formatted with PHP currency and 1 decimal place]
Your cost w tax: {total cost plus tax calculated in 3d above, formatted with PHP currency and 1 decimal place}

"""
#Start your code below

Solutions

Expert Solution

PYTHON CODE:

# getting item 1 name
item1_name = input('Item 1? ')

# getting item 1 price
item1_price = input('Item 1 price? ')

# getting item 1 quantity
item1_quantity = input('Item 1 number? ')
print()

# getting item 2 name
item2_name = input('Item 2? ')

# getting item 2 price
item2_price = input('Item 2 price? ')

# getting item 2 quantity
item2_quantity = input('Item 2 number? ')
print()

# getting item 3 name
item3_name = input('Item 3? ')

# getting item 3 price
item3_price = input('Item 3 price? ')

# getting item 3 quantity
item3_quantity = input('Item 3 number? ')
print()

# converting the string to float, integer
item1_price = float(item1_price)
item1_quantity = int(item1_quantity)
                  
item2_price = float(item2_price)
item2_quantity = int(item2_quantity)

item3_price = float(item3_price)
item3_quantity = int(item3_quantity)

# calculating the total cost

total_cost = item1_price * item1_quantity + (item2_price * item2_quantity) + (item3_price * item3_quantity)

# calculating tax and adding with total cost
total_cost_with_tax = total_cost + total_cost * .0545

# displaying the result
print('You ordered: {0:s} {1:s} {2:s}'.format(item1_name,item2_name,item3_name))
print('Your cost: ${:,.1f}'.format(total_cost))
print('Your cost w tax: ${:,.1f}'.format(total_cost_with_tax))


SCREENSHOT FOR CODING:

SCREENSHOT FOR OUTPUT:


Related Solutions

Python Programming- 9.12 S80 MT Practice 2 """ Enhance your simple food receipt a. Ask the...
Python Programming- 9.12 S80 MT Practice 2 """ Enhance your simple food receipt a. Ask the user for inputs about two food items using the following prompts in turn [add a space after each question mark]. Do not forget to assign each user entry to a unique variable name (do not display the Note to add a space just use print() to add a space between each set of input statements): Name 1? [add a space after the question mark]...
Python Programming- 9.11 S80 MT Practice1 #This is a template for practicing mutability and conversion #Create...
Python Programming- 9.11 S80 MT Practice1 #This is a template for practicing mutability and conversion #Create and assign the following list of numbers to a list data type and variable name: 88.5, 90, 75, 70, 85.6 #convert the list to a tuple and assign the tuple a different variable name #Ask the user for a grade and convert it to a float type (no prompt) and assign it to a new variable name #append the user entered grade to the...
Python Programming Write a simple implementation of a card deck to deal cards out randomly. Your...
Python Programming Write a simple implementation of a card deck to deal cards out randomly. Your Deck class will contain a list of card objects. Initially, the deck will contain one instance of each of the 52 possible cards. Your deck should implement a deal() method that chooses a random location from the list and "pops" that card. You should also implement a cardsLeft method that tells how many cards are left in the deck. Please type code and include...
Python Programming- Practice Lists & Tuples B #This is a template for practicing mutability and conversion...
Python Programming- Practice Lists & Tuples B #This is a template for practicing mutability and conversion #Create and assign the following list of numbers to a list data type and variable name: 99.9,88.7,89,90,100 #convert the list to a tuple and assign the tuple a different variable name #Ask the user for a grade and convert it to a float type (no prompt) and assign it to a new variable name #append the user entered grade to the list #update the...
You want to write a simple python program for a food delivery company that asks the...
You want to write a simple python program for a food delivery company that asks the office worker how many drivers they require to deliver their packages to different parts of town. When the user enters the number of drivers, the program will ask how many packages each driver will carry to its destination. It will then calculate the total number of packages and display the result on the screen as below. Sample run: How many drivers do you need?...
Prompt: This exercise uses your programming environment to enhance the Web site you created last week...
Prompt: This exercise uses your programming environment to enhance the Web site you created last week with additional functionality to include images, tables and a Form using Python flask. Specifically, you will add two (2) additional routes allowing a user to register and login to a web site. Additional security considerations include other routes (beyond the register route) will not be accessible until a successful login has occurred. In addition to the requirements list above the following functionality should be...
CODE IN PYTHON: Your task is to write a simple program that would allow a user...
CODE IN PYTHON: Your task is to write a simple program that would allow a user to compute the cost of a road trip with a car. User will enter the total distance to be traveled in miles along with the miles per gallon (MPG) information of the car he drives and the per gallon cost of gas. Using these 3 pieces of information you can compute the gas cost of the trip. User will also enter the number of...
a. In your own words, explain what is meant by good programming practice. Give two examples,...
a. In your own words, explain what is meant by good programming practice. Give two examples, one with good programming practice and one without good programming practice Note:java Programming Language
DIRECTIONS: Complete the following Programming Exercise in Python. Name the file Lastname_Firstname_E1. You just started your...
DIRECTIONS: Complete the following Programming Exercise in Python. Name the file Lastname_Firstname_E1. You just started your summer internship with ImmunityPlus based in La Crosse, Wisconsin. You are working with the forecasting team to estimate how many doses of an immunization drug will be needed. For each drug estimation, you will be provided the following information: corona.txt 39 20 31 10 42 49 54 21 70 40 47 60 - The size of the target population. - The life expectancy, in...
(20 pts) Using your programming language of choice (from C++, Java, or Python) , also drawing...
(20 pts) Using your programming language of choice (from C++, Java, or Python) , also drawing on your experience from program 1, read an integer, n from keyboard (standard input). This integer represents the number of integers under consideration. After reading that initial integer in, read n integers in, and print the minimum and maximum of all the integers that are read in. Example: Input Output 7 1 5 3 6 9 22 2 Min: 1 Max: 22 C++ preferred
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT