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

제목2020 1학기 기출 질문드립니다.2021-12-03 01:21
작성자
첨부파일캡처.PNG (84.6KB)

첨부한 사진의 문제입니다


(A)

class RemoteControl: 


    __enabledChannelList = list()

    

    def powerOnRemoteControl(clist):

        RemoteControl.__enabledChannelList = clist

        RemoteControl.recentNum = clist[0][0]

        RemoteControl.recentChannel = clist[0][1]

        return len(clist)



1번까지를 이렇게 짰는데,  채점이 진행될 때 입력파라미터가 어떻게 주어질지 모르겠습니다.

위 같이 짠 상태에서 


RemoteControl.powerOnRemoteControl([[6,"SBS"],[7,"KBS2"],[9,"KBS1"],[11,"MBC"]])


셀창에 위 문장을 입력하면 정확히 입력이 되는데,


(B)

class RemoteControl():

    def __init__(self):

        self.nowChannel_index = 0

        self.__enabledChannelList = []

        self.enabledNumberList= []

        self.nowChannel = []

        self.blockChannelList = []

        self.favorlist = {}

        

    def powerOnRemoteControl(self, clist):

        self.__enabledChannelList = clist

        self.nowChannel = clist[0]

        for i in range(len(clist)):

            self.enabledNumberList.append(clist[i][0])

        return len(clist)


이렇게 짠 상태에서 위의 RemoteControl.powerOnRemoteControl([[6,"SBS"],[7,"KBS2"],[9,"KBS1"],[11,"MBC"]])을 입력하면 오류가납니다.


채점이 진행될 때, 예를 들어

Remote = RemoteControl() 로 객체를 먼저 만들고 

Remote.powerOnRemoteControl([[6,"SBS"],[7,"KBS2"],[9,"KBS1"],[11,"MBC"]]) 처럼 메소드가 실행이 되는건지,


아니면 RemoteControl.powerOnRemoteControl([[6,"SBS"],[7,"KBS2"],[9,"KBS1"],[11,"MBC"]]) 이 코드가 실행이 되게 짜는걸까요?


첫번째 코드 (A)에 

Remote = RemoteControl() 

Remote.powerOnRemoteControl([[6,"SBS"],[7,"KBS2"],[9,"KBS1"],[11,"MBC"]]) 

를 대입하면 또 오류가납니다.


첫번째 코드(A)가 정답인가요? 두번째 코드(B)가 정답인가요?


출제 의도와 채점 기준이 궁금해서 질문드립니다

댓글