#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목2020-1학기 기출문제 질문2022-06-14 16:20
작성자
class RemoteControl:
    '''
    powerOnRemoteControl, gotoChannel, nextChannel, previousChannel,
    blockChannel, unblockChannel, powerOffRemoteControl, favorChannel, aiNextChannel
    '''    
    __enabledChannelList = [[6,"SBS"],[7,"KBS"],[9,"KBS1"],[11,"MBC"]]

    def __init__(self):
        self.__enabledChannelList = []
        self.channel_count = []


    def powerOnRemoteControl(self, channel_list):
        self.__enabledChannelList = channel_list
        self.nowChannel = channel_list[0]

        for i in range(len(channel_list)):
            self.channel_count.append(self.__enabledChannelList[i][0])
        return len(channel_list)

R = RemoteControl
print(R.powerOnRemoteControl(channel_list=[[6,"SBS"],[7,"KBS"],[9,"KBS1"],[11,"MBC"]]))

예외가 발생했습니다. TypeError
powerOnRemoteControl() missing 1 required positional argument: 'self'
File "C:\Users\small\OneDrive\바탕 화면\웹파이썬\기말고사\2020-1학기 기출 연습.py", line 35, in <module> print(R.powerOnRemoteControl(channel_list=[[6,"SBS"],[7,"KBS"],[9,"KBS1"],[11,"MBC"]]))


위 코드가 문제 조건에 맞는 지에 판단하기 위해 class 코드 밑에 print(R.powerOnRemoteControl(~))을 통해 출력해보았습니다.

하지만 self 의 값이 없어서 위와 같은 오류가 발생했습니다. 혹시 self는 인스턴스로 원래 값을 주지 않아도 실행이 되야 하는 것 아닌가요?

답변 감사합니다.


댓글
이전[re]2020겨울계절 기출질문입니다.2022-06-15
다음[re]2020-1학기 기출문제 질문2022-06-14