← Back to list

Coding for Bartender Cocktail Prep

By: Erika Rockwell

Erika Rockwell · 2026-03-20 05:15 · 1 claps · 4.8 min read
#bartending #coding #pytho #service-industry #restaurant
Open on Medium ↗
Wiki topics: 💻 · Programming 🍳 · Food & Cooking

Coding for Bartender Cocktail Prep

By: Erika Rockwell

Corbeaux Wine, Tea House, & Restaurant

Corbeaux Wine, Tea House, & Restaurant

A little background on me, I had exactly zero experience with coding before taking this class. It wasn’t something I necessarily disliked. But rather, I was intimidated by it. I’d never consider myself “Techy”; however, from day one, I realized that this did fit into my wheelhouse. It was a tool for problem-solving.

Like many of us in the engineering field, I love a good problem. Or even better, I like to create a problem. So, what was a problem for me that could be made simpler with the help of Python? My job. For the last four or five years, I’ve worked in the restaurant/service industry; for the past year and a half, I was at a fine-dining restaurant.

Corbeaux Wine, Tea House, & Restaurant

Corbeaux Wine, Tea House, & Restaurant

With fine dining comes a faster-paced, more technical approach. People are paying a higher price, and your service must reflect that. For me, I worked closely with the bar manager. I was head of bar prep and ordering. I even created many of the cocktails. But the biggest issue that plagued and sometimes impacted the entire flow of service was the issue of running out of ingredients for cocktails. Sometimes a singular ingredient like lemon juice or demerara syrup is featured in over half of a menu's cocktail list. Having this overlap can cause shattering effects after a whirlwind service, and having half of a cocktail menu “86'd” or unavailable is just not really an option. Now, lemon juice and simple syrup may be quick fixes, but the big issue is when it comes to more complex cocktails. Many of the cocktails I was making during prep day to day could sometimes require one hour to even three days of preparation. Between clarified cocktails and sous videing a variety of ingredients into liquor, there come major issues when even one item falls on the back burner.

So first, I started with creating a pseudo-code for myself. I had many iterations on the goals or purpose of this code at first, and wasn’t exactly sure how I wanted it to start or end, but I knew there were a couple of big things that I needed to consider.

Pseudocode

math conversions
spill_tax

recipe
inventory
density
calculations

print function

It needed to contain unconventional conversions (grams to ounces). It needed a buffer. And lastly, which direction I want to calculate in, either based on what I have or what I’ve used.

import math

ML_PER_OZ = 29.5735

def round_down(value, decimals=2):
    factor = 10 ** decimals
    return math.floor(value * factor) / factor

Starting with the math first, I referred to YouTube to figure out the beginning steps to create a math.floor. I used the b001 math module video[1], which led me to the Python.org website[2], which had charts very similar to our textbook examples from class lectures.

Now that that was out of the way, I focused on a recipe that was complex enough but was manageable to break down during this testing phase. There needed to be unique buffers, and I found a value to represent the buffer allowance based on syrup densities using ChatGPT. And I began testing by giving myself a fake inventory to see what my output would be.

spill_tax = 0.08   # 8% loss

# Recipe 
recipe_oz = {
    "Orange Blossom Water": 20 / 29.5735,  
    "Super Lime": 0.75,
    "Yuzu Sureman": 0.50,
    "Pisco": 1.50,
    "Demerara syrup": 0.50,
    "Rhubarb bitters": 3 / 29.5735,  
    "Egg white": 0.75
}

# Inventory
inventory_grams = {
    "Orange Blossom Water": 400,
    "Super Lime": 900,
    "Yuzu Sureman": 600,
    "Demerara syrup": 1200,
    "Rhubarb bitters": 500,
    "Egg white": 1000,
}

pisco_bottles = 2  # 750ml bottles

# Density assumptions (g/ml)
densities = {
    "Super Lime": 1.03,
    "Yuzu Sureman": 1.03,
    "Demerara syrup": 1.30,
}

see_stock = ["Rhubarb bitters", "Egg white"]

Even after importing math, there were a couple of discrepancies I couldn’t resolve. This was due to ingredients being measured using dropper bottles or dasher stoppers. But those small discrepancies just require a bit more help. But it was really the if, elif, else module in class that made things start to finally click in my head on how I could make this concept into a reality.

# CALCULATION
possible_counts = {}

for ingredient, amount_needed_oz in recipe_oz.items():

    if ingredient == "Pisco":
        total_ml = pisco_bottles * 750
        total_oz = total_ml / ML_PER_OZ
        usable_oz = total_oz * (1 - spill_tax)
        usable_oz = round_down(usable_oz)

    else:
        grams = inventory_grams.get(ingredient, 0)
        density = densities.get(ingredient, 1.0)
        ml = grams / density
        oz = ml / ML_PER_OZ
        usable_oz = oz * (1 - spill_tax)
        usable_oz = round_down(usable_oz)

    cocktails_possible = math.floor(usable_oz / amount_needed_oz)
    possible_counts[ingredient] = cocktails_possible

# Remove "see stock" items from limiting
limiting_pool = {k: v for k, v in possible_counts.items()\
if k not in see_stock}

max_cocktails = math.floor(min(limiting_pool.values()))
limiting_ingredient = min(limiting_pool, key=limiting_pool.get)

Now the see stock did raise some issues for me as I wasn’t really sure how to redirect my code, so the k and v were placeholder values I created. This was a way of creating shortcut placeholder values that made things a bit neater for me.

# --- OUTPUT ---
print("\nYou can make:", max_cocktails, "cocktails")
print("Limiting ingredient:", limiting_ingredient)

print("\nBreakdown:")
for k, v in possible_counts.items():
    tag = ""
    if k == limiting_ingredient:
        tag = " <-- LIMIT"
    if k in see_stock:
        tag = " (SEE STOCK)"
    print("-", k, ":", v, tag)

Final Code Output

Final Code Output

Overall, I’m very happy with this code and happy that I actually understand it. This is clearly very beginner code, but I think it's a good start to what purpose I think it can serve. To improve, I’d like to add more. To make it a loop statement that allows you to put in what inventory you’ve stocked up on that day. Or have an input function after the breakdown that lets you put in how many cocktails you actually sold. All in all, there are a multitude of ways to improve this code, and I’m happy that I was able to create something that I’m not only proud of but something that's truly useful for me and the industry.

Rhubarb Sour from Corbeaux Wine, Tea House, & Restaurant

Rhubarb Sour from Corbeaux Wine, Tea House, & Restaurant

Works Cited:

[1] b001. (2022, October 10). The Python Math Module Explained. YouTube. https://www.youtube.com/watch?v=ZxJs4M0qPqA

[2] Math — mathematical functions. Python documentation. (n.d.). https://docs.python.org/3/library/math.html

[3] Bea Glaze 1, Larsks — Larsks, Daniel Hao — Daniel Hao, TigerhawkT3 — TigerhawkT3, & Lime 39255 silver badges1717 bronze badges. (2022, June 19). How does the for-loop with K, V in contact_emails.items(): Work?. Stack Overflow. [https://stackoverflow.com/questions/72680234/how-does-the-for-loop-with-k-v-in-contact-emails-items-work#:~:text=The%20for%2Dloop%20with%20%60k%2C%20v%20in%20contact_emails.items()%60,into%20two%20different%20variables%20using%20tuple%20unpacking](https://stackoverflow.com/questions/72680234/how-does-the-for-loop-with-k-v-in-contact-emails-items-work#:~:text=The%20for%2Dloop%20with%20%60k%2C%20v%20in%20contact_emails.items()%60,into%20two%20different%20variables%20using%20tuple%20unpacking)


메타데이터
post_id
960857be56e1
slug
coding-for-bartender-cocktail-prep-960857be56e1
url
https://medium.com/@ejrockwell/coding-for-bartender-cocktail-prep-960857be56e1
canonical_url
https://medium.com/@ejrockwell/coding-for-bartender-cocktail-prep-960857be56e1
author_url
https://medium.com/@ejrockwell
status
ok
fetched_at
2026-06-29 22:44:20