Access Variables from Different Methods Dry Run in PYTHON

Access Variables from Different Methods is an interactive PYTHON dry run visualizer from the Accessmodifiers 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.

Access Variables from Different Methods Program Code

class StudentAccess:
    def __init__(self):
        self.name = "Anu"
        self._marks = 85
        self.__pin = 4321

    def show_public(self):
        print("Public in method:", self.name)

    def show_protected(self):
        print("Protected in method:", self._marks)

    def show_private(self):
        print("Private in method:", self.__pin)

    def show_all(self):
        print("All inside method:", self.name, self._marks, self.__pin)

s1 = StudentAccess()

print("Outside public:", s1.name)
print("Outside protected:", s1._marks)

s1.show_public()
s1.show_protected()
s1.show_private()
s1.show_all()

View the complete Accessmodifiers programs page.

Program Console Access Variables from Different Methods Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.