Constructor with Optional Value Dry Run in PYTHON

Constructor with Optional Value is an interactive PYTHON dry run visualizer from the Constructors 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.

Constructor with Optional Value Program Code

class Course:
    def __init__(self, name, duration=None):
        self.name = name
        self.duration = duration

c1 = Course("Python")
c2 = Course("Java", "3 months")
print(c1.name, c1.duration)
print(c2.name, c2.duration)

View the complete Constructors programs page.

Program Console Constructor with Optional Value Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.