Medicine Stock Update Dry Run in PYTHON

Medicine Stock Update is an interactive PYTHON dry run visualizer from the Encapsulation programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Medicine Stock Update Program Code

class Medicine:
    def __init__(self):
        self.__stock = 20

    def sell(self, quantity):
        if quantity <= self.__stock:
            self.__stock = self.__stock - quantity
            print("Sold:", quantity)

    def show_stock(self):
        print("Stock left:", self.__stock)


m1 = Medicine()
m1.sell(5)
m1.show_stock()

View the complete Encapsulation programs page.

Program Console Medicine Stock Update Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.