-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass_test.py
More file actions
34 lines (31 loc) · 805 Bytes
/
class_test.py
File metadata and controls
34 lines (31 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Student(object):
"""docstring for Student"""
def __init__(self,name,score):
# if not isinstance(str,name):
# raise ValueError
# if score>100 or score<0:
# raise ValueError
self.__score = score
self.__name = name
# def get_name(self):
# if not isinstance(str,name):
# print("The student's name is %s" %self.__name)
def get_grade(self):
if not isinstance(self.__score,int):
raise ValueError
if self.__score>100 or self.__score<0 :
raise ValueError
if self.__score >= 80:
return 'A'
elif self.__score >= 60:
return 'B'
return 'C'
# def set_sex(self,sex):
# if not isinstance(sex,str):
# print("error! not a string")
# return
# self.__sex=sex
def get_name(self):
if not isinstance(self.__name,str):
raise ValueError
return self.__name