Python출력 결과보통 · 20점#클래스#변수

273. 메서드에서 self로 클래스 변수 늘리기

다음 Python 프로그램의 실행 결과를 쓰시오.

1class Ticket:
2 count = 0
3
4 def __init__(self):
5 Ticket.count += 1
6
7 def use(self):
8 self.count += 1
9
10
11t1 = Ticket()
12t2 = Ticket()
13t1.use()
14t1.use()
15print(Ticket.count, t1.count, t2.count)
16Ticket.count = 7
17print(t1.count, t2.count)

해설을 먼저 보면 이후 정답 시 점수가 50%만 반영됩니다.