Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson16_4
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
abbb6b57
authored
Jun 25, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
26fd95f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
31 deletions
hwh.py
sb.py
hwh.py
View file @
abbb6b57
#
class Stubit:
class
Stubit
:
#
def __init__(self,name,age,score):
def
__init__
(
self
,
name
,
age
,
score
):
#
self.name = name
self
.
name
=
name
#
self.age = age
self
.
age
=
age
#
self.score = score
self
.
score
=
score
#
def get_name(self):
def
get_name
(
self
):
#
return self.name
return
self
.
name
#
def get_age(self):
def
get_age
(
self
):
#
return self.age
return
self
.
age
#
def get_score(self):
def
get_score
(
self
):
#
return max(self.score)
return
max
(
self
.
score
)
#
stubit = Stubit("潘伞兵",8,[10,22,5])
stubit
=
Stubit
(
"潘伞兵"
,
8
,[
10
,
22
,
5
])
#
print(stubit.get_name())
print
(
stubit
.
get_name
())
#
print(stubit.get_age())
print
(
stubit
.
get_age
())
#
print(stubit.get_score())
print
(
stubit
.
get_score
())
class
C
:
#
class C:
def
__init__
(
self
,
m
,
mo
):
#
def __init__(self,m,mo):
self
.
m
=
m
#
self.m =m
self
.
mo
=
mo
#
self.mo =mo
def
output_c
(
self
):
#
def output_c(self):
return
"制造商"
+
self
.
m
+
",型号"
+
self
.
mo
#
return "制造商" + self.m + ",型号" + self.mo
class
Ec
(
C
):
#
class Ec(C):
def
__init__
(
self
,
m
,
mo
,
bs
):
#
def __init__(self,m,mo,bs):
super
()
.
__init__
(
m
,
mo
)
#
super().__init__(m,mo)
self
.
bs
=
bs
#
self.bs =bs
def
output_b
(
self
):
#
def output_b(self):
return
"这辆汽车还有"
+
str
(
self
.
bs
)
+
"千瓦时电量"
#
return "这辆汽车还有" + str(self.bs) + "千瓦时电量"
mc
=
Ec
(
"比亚迪"
,
"汉-超跑版"
,
60
)
# mc = Ec("比亚迪" , "汉-超跑版" , 60)
print
(
mc
.
output_c
())
# print(mc.output_c())
print
(
mc
.
output_b
())
# print(mc.output_b())
\ No newline at end of file
\ No newline at end of file
sb.py
0 → 100644
View file @
abbb6b57
class
st
:
def
__init__
(
self
,
name
,
age
,
score
):
self
.
name
=
name
self
.
age
=
age
self
.
score
=
score
def
get_game
(
self
):
return
self
.
name
def
get_age
(
self
):
return
self
.
age
def
get_score
(
self
):
return
max
(
self
.
score
)
sb
=
st
(
"hwh"
,
12
,[
0
,
0
,
1
])
print
(
sb
.
get_game
())
print
(
sb
.
get_age
())
print
(
sb
.
get_score
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment