order pizza in python

Here's a fun way to order pizza using Python:

main.py
# import required libraries
import webbrowser
import time

# set pizza order details
pizza_size = input("What size do you want? S, M, L, or XL? ")
pizza_crust = input("What type of crust do you want? Thin, thick, or stuffed? ")
pizza toppings = input("What toppings do you want? Please separate with a comma. ")

# build url to order pizza
pizza_url = "https://www.dominos.com/en/pages/order/#/section/Food/category/AllEntrees/"

if pizza_size == "S":
    pizza_url += "productAttributes.10=10"
elif pizza_size == "M":
    pizza_url += "productAttributes.10=11"
elif pizza_size == "L":
    pizza_url += "productAttributes.10=12"
elif pizza_size == "XL":
    pizza_url += "productAttributes.10=34"

if pizza_crust == "Thin":
    pizza_url += "&productAttributes.P0=PAN"
elif pizza_crust == "Thick":
    pizza_url += "&productAttributes.P0=CRUST17"
elif pizza_crust == "Stuffed":
    pizza_url += "&productAttributes.P0=STS"

toppings_list = toppings.split(",")
toppings_num = len(toppings_list)
for i in range(toppings_num):
    if i == 0:
        pizza_url += "&productAttributes.1="
    else:
        pizza_url += "%2C"
    pizza_url += toppings_list[i]

pizza_url += "&quantity=1&toppingsCount=%s" % toppings_num

# open the pizza webpage after a 3 second delay
time.sleep(3)
webbrowser.open(pizza_url)
1305 chars
43 lines

This code asks for the size, crust, and toppings of the pizza, and then generates a URL that will take you to the Domino's website to place an order with those specifications. The webbrowser and time modules are used to automatically open the webpage after a few seconds.

Note that this is just a fun example and is not meant to be used for actual pizza orders.

related categories

gistlibby LogSnag