logo CodeStepByStep logo

class_tracing

Language/Type: Python classes

What is the output of the following program? Write each of the four lines as it would appear on the console.

class Date:
    def __init__(self, m, d):
        self.month = m
        self.day = d

def add_to_month_twice(a, d):
    a = a + a
    d.month = a
    print(a, d.month)

def main():
    a = 7
    b = 9
    d1 = Date(2, 2)
    d2 = Date(2, 2)
    add_to_month_twice(a, d1)
    print(a, b, d1.month, d2.month)
    add_to_month_twice(b, d2)
    print(a, b, d1.month, d2.month)

main()
line 1
line 2
line 3
line 4

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.