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...
2.13 Program: Food receipt (Python 3) 1.Enter food item name: hot dog Enter item price: 2...
2.13 Program: Food receipt (Python 3) 1.Enter food item name: hot dog Enter item price: 2 Enter item quantity: 5 RECEIPT 5 hot dog @ $ 2.0 = $ 10.0 Total cost: $ 10.0 2.Enter food item name: hot dog Enter item price: 2 Enter item quantity: 5 RECEIPT 5 hot dog @ $ 2.0 = $ 10.0 Total cost: $ 10.0 Enter second food item name: ice cream Enter item price: 2.50 Enter item quantity: 4 RECEIPT 5 hot...
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?...
COSC 1436 Programming Assignment : Skill Practice Assignment 3 Your skill practice assignment this week will...
COSC 1436 Programming Assignment : Skill Practice Assignment 3 Your skill practice assignment this week will be programming challenge #6 on page 374 - Kinetic Energy In it you are asked to write a programing that returns the amount of kinetic energy the object has. You will ask the user to enter values for mass and velocity. You will need to create a function named kinetic Energy that accepts an object's mass (in kilograms) and velocity (in meters per second)...
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT