파이썬아시는분있나요 ? 클래스쪽배우고있는데요

   조회 2904   추천 0    

수능성적표 만드는 과제인데요 

잘안되어서요 요기밑에 우선 제가 써본건데 

뭐가문제인지봐줄수있으신분 계신가요 ?

클래스를이용하여  학교이름수헙번호등급백분위 나오게하는것이에요 




class student:

    def __init__(self, name=None, highSchool=None, number=0, natScore=0, matScore=0, engScore=0):
   
                 self.__name=name

                 self.__highSchool=highSchool

                 self.__number=number

                 self.__natScore=natScore

                 self.__matScore=matScore

                 self.__engScore=engScore

 

    def setName(self, name):

        self.__name=name

 

    def getName(self):

        return self.__name

 

    def setHighSchool(self, highSchool):

        self.__highSchool=highSchool

 

    def getHighSchool(self):

        return self.__highSchool

 

    def setnatScore(self, natScore):

        self.__natScore=natScore

 

    def getnatScore(self):

        return self.__natScore

 

    def setmatScore(self, matScore):

        self.__matScore=matScore

 

    def getmatScore(self):

        return self.__matScore

 

    def setengScore(self, engScore):

        self.__engScore=engScore

 

    def getengScore(self):

        return self.__engScore

 

def clacNatGrade(self):

    if self.__natScore>=90:

        self.__natScore= '1등급'

    elif self.__natScore>=80:

        self.__natScore= '2등급'

    elif self.__natScore>=70:

        self.__natScore= '3등급'

    elif self.__natScore>=60:

        self.__natScore= '4등급'

    elif self.__natScore>=50:

        self.__natScore= '5등급'

    elif self.__natScore>=40:

        self.__natScore= '6등급'

    elif self.__natScore>=30:

        self.__natScore= '7등급'

    elif self.__natScore>=20:

        self.__natScore= '8등급'

    else:

        self.__natScore= '9등급'

 

def clacMatGrade(self):

    if self.__matScore>=90:

        self.__matScore= '1등급'

    elif self.__matScore>=80:

        self.__matScore= '2등급'

    elif self.__matScore>=70:

        self.__matScore= '3등급'

    elif self.__matScore>=60:

        self.__matScore= '4등급'

    elif self.__matScore>=50:

        self.__matScore= '5등급'

    elif self.__matScore>=40:

        self.__matScore= '6등급'

    elif self.__matScore>=30:

        self.__matScore= '7등급'

    elif self.__matScore>=20:

        self.__matScore= '8등급'

    else:

        self.__matScore= '9등급'

 

def clacEngGrade(self):

    if self.__engScore>=90:

        self.__engScore= '1등급'

    elif self.__engScore>=80:

        self.__engScore= '2등급'

    elif self.__engScore>=70:

        self.__engScore= '3등급'

    elif self.__engScore>=60:

        self.__engScore= '4등급'

    elif self.__engScore>=50:

        self.__engScore= '5등급'

    elif self.__engScore>=40:

        self.__engScore= '6등급'

    elif self.__engScore>=30:

        self.__engScore= '7등급'

    elif self.__engScore>=20:

        self.__engScore= '8등급'

    else:

        self.__engScore= '9등급'

임상일
짧은글 일수록 신중하게.
진곤김 2019-05
막상 숙제하느라 조바심 나시겠지만 호기심에 적어봅니다

등급계산 기능이 전체 요구사항에비해 코드길이가 깁니다
일단 한줄로 처리합니다
— grade 계산 중복 —> 함수하나로 추출 —> (10 - 점수의10의자리) 하면 1..9 등급추출

요구사항 분석을 더 구체화해서 요구한것만 최소로 러프하게 만듭니다 이쁘게 만들려면 끝이 없습니다 (getter/setter, 파이썬클래스 매직 활용들)

고객요청: “학교이름/수헙번호/등급백분위(누락)” 나오게하는

설계
아이템관리, 아이템 두개의 클래스를 1:다 관계로 만들고
아이템관리에
- 아이템의 점수에따른 정렬기능 필요
- 출력기능추가
아이템에
- 수험번호/학교/국/영/수 값저장
아이템관리, 아이템 클레스에 기능요구사항을 적절히 배분하세요

테스트로 사용할 10개정도의 아이템을 먼저 정의한후에 위설계한 내용을 하나씩 코드로 변환 /테스트하면서 구현합니다
Dreaday 2019-05
4개 이상의 조건이라면 switch case문 하면 좋을 것 같습니다
     
chis 2019-05
파이썬은 스위치문이 없을거에요..
무아 2019-05
잘 안된다고 하셨는데 어느 부분이 안되는지 설명이 빠졌어요.
일단 한 가지 이해 안가는 부분이..
if self.__engScore>=90:
        self.__engScore= '1등급'
이런 식의 문장이 보이는데..
self.__engScore 의 자료형 뭔가요? int? string?
파이썬은 이런 거 구분하지 않는 건가요?? 잘 몰라서..
자료형이 막 혼용되고 있네요.
만약 혼용이 된다고 하더라도. 나중에 스트링을 정수와 비교하는 상황이 생길 듯 한데요.


QnA
제목Page 840/5706
2015-12   1666192   백메가
2014-05   5131412   정은준1
2024-05   2896   VSPress
2024-02   2897   빅픽챠
2023-03   2897   신은왜
2020-04   2897   검은콩
2020-07   2897   나비z
2020-04   2897   오성기
2023-06   2897   풀로드시스템
2019-03   2897   행복하세
2021-10   2897   limitroc
2020-01   2897   수퍼싸이언
2021-02   2897   컴박
2020-04   2897   최시영
2020-09   2897   행복하세
2019-12   2897   강한구
2020-03   2897   미수맨
2019-12   2897   AKMU
2021-11   2897   SEEART
2019-01   2898   광주동키호테
2020-10   2898   Lucifer
2020-07   2898   장동건2014