Did you ever have a lemonade stand as a kid? I did. I was six or seven years old, and I really wanted to buy a few hockey trading card packs at the convenience store down the block. That was back when the cards would come with a strip of bubble gum. (They still do, right?) I didn't have the money, and while my dad wasn't willing to hand over a few bucks for cards, he was happy to provide the funds I needed to start my own lemonade stand instead.
Turns out, selling lemonade is a perfect scenario to introduce dynamic pricing and price optimization techniques. In this post, we'll be finding an optimal price for our glasses of lemonade using some basic methodology in Python in order to maximize our revenue.
In revenue management literature, our lemonade stand would be a case of:

Timedated items: In a nutshell, that means that I can only sell my lemonade for a certain amount of time. In my case, I could sell lemonades between about 9 a.m. and the time I was expected to be home for dinner; let's say 7 p.m. So I can sell lemonade for only 10 hours.

Perishable capacity with no salvage value: After spending most of the day in the sun, my lemonade will go bad and turn sour by 78 p.m. I couldn't sell the remaining glasses (even at discount!) to my younger neighbor Cedric across the street to give to his sisters. He didn't like the taste.

Marketplace with no competing products (monopolistic situation): I didn't try to sell anything besides lemonade and I was lucky enough to be the only kid in the neighborhood selling it. The fourth graders running the lemonade mafia were living across town.

Absence of inventory replenishment: I biked to the store in the morning to buy my lemons and sugar, but didn't have time to go back to the store during lunch. I was stuck with whatever inventory I bought in the morning with no prospect of adding to it during the day.
In addition to these characteristics, we will add a few limiting features to simplify our approach to price optimization. We will make the assumptions that there is:

An infinite number of customers: The customer population size does not enter in the model

Customers are myopic: In other words, customers buy as soon as the price is less than the one they are prepared to pay. Some customers are savvier than others and can modify their behaviors according to your pricing strategy. However, we will ignore them for now.
These assumptions are somewhat simplistic, but they will allow us to cover the basic concepts behind price optimization without going over complicated edge cases and mathematical formulation. Those will be the subject of future posts!
First, let's go over the mathematical formulation of the problem.