Python출력 결과기초 · 10점#클래스#상속#오버라이딩#입문

143. 상속받은 메서드 다시 정의하기

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

1class Animal:
2 def sound(self):
3 return "소리"
4
5
6class Cat(Animal):
7 def sound(self):
8 return "야옹"
9
10
11class Cow(Animal):
12 pass
13
14
15a = Cat()
16b = Cow()
17x = a.sound()
18y = b.sound()
19print(x, y)

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