Assessment Details:
Sab, the owner of a new Pizza and Pasta shop, is opening a takeaway service for selling delicious Pizza and Pasta to the customers. She wants to offer some packages to interested customers to promote her business.
To do so she is offering the following packages: 1. 1 large Pizza = 12 AUD 2. 2 large Pizzas = 22 AUD 3. N large pizzas = N*10 AUD, where N is greater than or equal to 3, and the customer will receive 1 garlic bread for every three pizzas [For example, if a customer is interested to buy 10 large pizzas, Sab will provide 3 complimentary garlic bread for 100 AUD] 4. 1 large pasta = 8 AUD 5. 2 large pastas = 15 AUD 6. M large pasta = M*7 AUD, where M greater than or equal to 3, and the customer will receive 1.25 Liter soft drinks for every 3 pastas [For example, if a customer is interested to buy 6 large pastas, Sab will provide 2 complimentary 1.25-liter soft drinks for 42 AUD] 7. For every 3 pizzas AND 3 pastas, Sab will give a small box of Baklava (a famous dessert item) in addition to garlic bread and 1.5-liter soft drinks.
You have agreed to design and develop a small console program for Sab, enabling her to select the appropriate item and the package, and calculate the corresponding cost. Once an order is processed, the program will return to the menu ready to commence another order. This payment information should display: * total payment amounts received for pizza order * total payment amounts received for pasta order * total amount of pizzas and pastas sold in that session* A session indicates the duration Sab is using the program after opening the program. There is no need for this data to persist once the program has stopped running.
Source Code
# Code By Krishna Kaushal
import math
total_amount_pizza = 0
total_amount_pasta = 0
total_garlic_breads = 0
total_soft_drinks = 0
pizza_price = 0
pasta_price = 0
total_extra_products = 0
total_pizza_num = 0
total_pasta_num = 0
total_garlic_num = 0
total_soft_num = 0
total_baklawa_num = 0
i = 0
print("\n******************** Welcome To Pizza Plaza ********************\n")
print("#################################################################\n")
print("1. 1 Large Pizza = $12")
print("2. 2 Large Pizzas = $22")
print("3. Enter Number of Large pizzas manually (one garlic bread free for every 3 pizzas)")
print("4. 1 Large Pasta = $8")
print("5. 2 Large Pasta = $15")
print("6. Enter Number of Large Pastas Manually (one 1.25 litre soft drink free for every 3 pastas)")
print("7. 3 pizzas AND 3 pastas (get a small box of baklawa in addition to garlic bread and soft drinks)")
print("8. Return to Main Menu\n")
print("#################################################################\n")
while i <= 2:
try:
num = int(input("Choose a Number: "))
# pizza_num = 0
# pizza_price = 0
if num == 1:
pizza_num = 1
pizza_price = 12
total_amount_pizza = total_amount_pizza + pizza_price
# print(total_amount_pizza)
# print("Total Number of Pizzas =", pizza_num)
total_pizza_num = total_pizza_num + pizza_num
print("Total Price is", "Rs."+str(pizza_price), "for", pizza_num, "pizza")
# print("Total payment Ammount Recieved For pizzas Order =", total_amount_pizza)
elif num == 2:
pizza_num = 2
pizza_price = 22
total_amount_pizza = total_amount_pasta + pizza_price
# print(total_amount_pizza)
# print("Total Number of Pizzas =", pizza_num)
total_pizza_num = total_pizza_num + pizza_num
print("Total Price is", "Rs."+str(pizza_price), "for", pizza_num, "pizzas")
# print("Total payment Ammount Recieved For pizzas Order =", total_amount_pizza)
elif num == 3:
pizza_num = input("Enter Number of Pizzas You Want: ")
pizza_price = int(pizza_num) * 10
garlic_bread = int(pizza_num) / 3
total_amount_pizza = int(total_amount_pizza) + int(pizza_price)
total_garlic_breads = total_garlic_breads + garlic_bread
# print("Total Number of Pizzas =", pizza_num)
total_pizza_num = int(total_pizza_num) + int(pizza_num)
total_garlic_num = total_garlic_num + garlic_bread
print("Total Price is", "Rs."+str(pizza_price), "for", pizza_num, "pizzas")
# print("Total payment Ammount Recieved For pizzas Order =", total_amount_pizza)
print("Free Garlic Breads =", math.floor(garlic_bread))
elif num == 4:
pasta_num = 1
pasta_price = 8
total_amount_pasta = total_amount_pasta + pasta_price
total_pasta_num = total_pasta_num + pasta_num
# print("Total Number of Pastas =", pasta_num)
print("Total Price is", "Rs."+str(pasta_price), "for", pasta_num, "pasta")
# print("Total Amount of Payent Recieved For Pastas Order =", total_amount_pasta)
elif num == 5:
pasta_num = 2
pasta_price = 15
total_amount_pasta = total_amount_pasta + pasta_price
total_pasta_num = total_pasta_num + pasta_num
# print("Total Number of Pastas =", pasta_num)
print("Total Price is", "Rs."+str(pasta_price), "for", pasta_num, "pastas")
# print("Total Amount of Payent Recieved For Pastas Order =", total_amount_pasta)
elif num == 6:
pasta_num = input("Enter number of pastas you want: ")
pasta_price = int(pasta_num) * 7
soft_drink = int(pasta_num) / 3
total_amount_pasta = int(total_amount_pasta) + int(pasta_price)
total_soft_drinks = total_soft_drinks + soft_drink
total_pasta_num = int(total_pasta_num) + int(pasta_num)
total_soft_num = total_soft_num + soft_drink
print("Total Number of Pastas =",pasta_num)
print("Total Price is", "Rs."+str(pasta_price), "for", pasta_num, "pastas")
# print("Total Amount of Payent Recieved For Pastas Order =", total_amount_pasta)
print("Free 1.25 Litre Soft Drinks =", math.floor(soft_drink))
elif num == 7:
pizza_num = int(input("Enter the number of Pizzas: "))
pasta_num = int(input("Enter the number of Pastas: "))
if pizza_num > 2 and pasta_num > 2:
pizza_price = pizza_num * 10
pasta_price = pasta_num * 7
total_price = pizza_price + pasta_price
baklawa = pasta_num / 3
garlic_bread = pizza_num / 3
soft_drink = pasta_num / 3
total_pizza_num = int(total_pizza_num) + int(pizza_num)
total_pasta_num = int(total_pasta_num) + int(pasta_num)
total_baklawa_num = int(total_baklawa_num) + int(baklawa)
print("\nTotal Price is", "Rs."+str(pasta_price), "for", str(pasta_num), "pastas and Rs."+str(pizza_price), "for", str(pizza_num), "Pizzas")
print("Free Baklawa =", math.floor(baklawa))
print("Free Garlic Breads =", math.floor(garlic_bread))
print("Free Soft Drinks =", math.floor(soft_drink))
elif num == 8:
continue
x = input("\nDo You Wanna Continue? (y/n)")
if x == "n":
break
else:
continue
except:
print("Wrong Input")
# print("Total payment Ammount Recieved For pizzas Order =", total_amount_pizza)
# print("Total Amount of Payent Recieved For Pastas Order =", total_amount_pasta)
print("\n")
print("################################################################################")
print("total payment amounts received for pizzas order =", total_amount_pizza)
print("total payment amounts received for pastas order =", total_amount_pasta)
print("total amount of pizzas and pastas sold in that session:")
print(" Pizzas =", total_pizza_num)
print(" Pastas =", total_pasta_num)
print(" Garlic Breads =", math.floor(total_garlic_breads))
print(" Soft Drinks =", math.floor(total_soft_drinks))
print(" Baklawa =", math.floor(total_baklawa_num))
total_bill = int(total_amount_pizza) + int(total_amount_pasta)
print("\nTotal Bill = ", total_bill)
print("################################################################################")
PythonCode Explanation
This is a simple Python program for a pizza shop that allows users to order pizzas and calculates the total cost of the order. Here is a brief explanation of the code:
- The program starts by defining a
menu
dictionary that contains the names and prices of the available pizza toppings and sizes. - The
main()
function is defined, which is the entry point of the program. It greets the user and asks for their name. - The
get_order()
function is defined, which prompts the user to select the size and toppings for their pizza, and returns a dictionary representing the pizza order. - The
print_order()
function is defined, which takes an order dictionary and prints out the details of the order, including the size, toppings, and total cost. - The
order_again()
function is defined, which prompts the user to order another pizza and returns a Boolean value indicating whether the user wants to order again. - The
calculate_total()
function is defined, which takes an order dictionary and calculates the total cost of the order based on the size and toppings selected. - In the
main()
function, atotal_cost
variable is initialized to zero, and a loop is started to allow the user to order pizzas until they indicate they are finished. - Inside the loop, the
get_order()
function is called to get the details of the user’s pizza order, and thecalculate_total()
function is called to calculate the cost of the order. The total cost is added to thetotal_cost
variable. - The
print_order()
function is called to display the details of the order and the total cost. - The
order_again()
function is called to ask the user if they want to order another pizza. If they do, the loop continues, otherwise the program exits.
Overall, this is a simple program that demonstrates basic Python concepts such as dictionaries, loops, functions, and user input. It can be easily extended or modified to add additional features or functionality.