Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_1
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
eb4a167c
authored
Oct 03, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
b225c7b6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
demo.py
diy.py
demo.py
0 → 100644
View file @
eb4a167c
r
=
float
(
input
(
'圆的半径:'
))
e
=
3.1456
print
(
"圆的直径是:
%.2
f"
%
(
2
*
r
))
print
(
"圆的周长是:
%.2
f"
%
(
2
*
e
*
r
))
print
(
'圆的面积是:'
,
round
(
r
*
r
*
e
,
2
))
\ No newline at end of file
diy.py
View file @
eb4a167c
#创建一个英雄类
#创建一个英雄类
class
Hero
:
class
Hero
:
def
__init__
(
self
):
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
1
#等级
self
.
level
=
1
#等级
self
.
hp
=
300
#血量
self
.
name
=
name
#名字
self
.
attack
=
25
#攻击力
self
.
hp
=
hp
#血量
self
.
attack
=
attack
#攻击力
def
upgrade
(
self
):
self
.
level
+=
1
self
.
hp
+=
50
self
.
attack
+=
5
#实例化对象
#实例化对象
yase
=
Hero
()
yase
=
Hero
(
'亚瑟'
,
300
,
25
)
houyi
=
Hero
()
houyi
=
Hero
(
'后羿'
,
240
,
40
)
yase
.
upgrade
()
houyi
.
upgrade
()
houyi
.
upgrade
()
print
(
'亚瑟的血量是'
,
yase
.
hp
)
print
(
'亚瑟的血量是'
,
yase
.
hp
)
print
(
'后羿的血量是'
,
houyi
.
hp
)
\ No newline at end of file
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