Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson13-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
dcea2c65
authored
Jul 12, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
7c9d3dee
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
182 additions
and
74 deletions
1.py
2.py
3.py
4.py
5.py
6.py
7.py
8.py
diy.py
new_sales_list.txt
sales_list.txt
1.py
View file @
dcea2c65
import
turtle
len
=
150
screen
=
turtle
.
Screen
()
screen
.
bgcolor
(
"blue"
)
pen
=
turtle
.
Pen
()
pen
.
penup
()
pen
.
goto
(
100
,
-
100
)
pen
.
write
(
"你好呀!"
,
font
=
(
"Times"
,
20
,
"normal"
))
pen
.
hideturtle
()
pen1
=
turtle
.
Pen
()
pen1
.
pensize
(
5
)
pen1
.
pencolor
(
"red"
)
pen1
.
left
(
45
)
pen1
.
forward
(
len
)
pen1
.
circle
(
len
/
2
,
180
)
pen1
.
right
(
90
)
pen1
.
circle
(
len
/
2
,
180
)
pen1
.
forward
(
len
)
pen1
.
hideturtle
()
turtle
.
done
()
\ No newline at end of file
2.py
View file @
dcea2c65
class
Hero
:
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
):
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
3
self
.
level
=
3
...
...
3.py
View file @
dcea2c65
txt
=
'wecome to the bellcode'
new_txt
=
txt
.
split
()
print
(
new_txt
)
txt1
=
"阿萨德,颚骨,七点,"
new_txt1
=
txt1
.
split
(
','
)
print
(
new_txt1
)
4.py
View file @
dcea2c65
class
Hero
:
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
10000
self
.
attack
=
4
self
.
name
=
name
def
combat
(
self
,
enemy
):
enemy
.
hp
-=
self
.
attack
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起攻击,"
info2
=
"造成"
+
str
(
self
,
attack
)
+
"点伤害,"
if
enemy
.
hp
>
0
:
info3
=
enemy
.
name
+
"还剩下"
+
str
(
enemy
.
hp
)
+
"血量"
info
=
info1
+
info2
+
info3
print
(
info
)
else
:
info3
=
enemy
.
name
+
"阵亡,游戏结束"
info
=
info1
+
info2
+
info3
print
(
info
)
exit
()
5.py
0 → 100644
View file @
dcea2c65
class
C
:
def
__init__
(
self
):
self
.
footnum
=
4
self
.
eyenum
=
2
self
.
head
=
1
self
.
earnum
=
2
self
.
skin
=
"black"
def
run
(
self
):
print
(
"小猫飞快地跑起来"
)
def
skill
(
self
,
prey
):
print
(
"小猫抓住了"
+
prey
)
role
=
Cat
()
role
.
skill
(
"老鼠"
)
6.py
0 → 100644
View file @
dcea2c65
class
Hero
:
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
10000
self
.
attack
=
4
self
.
name
=
name
def
combat
(
self
,
enemy
):
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起攻击,"
info2
=
"造成"
+
str
(
self
.
attack
)
+
"点伤害,"
enemy
.
hp
-=
self
.
attack
if
enemy
.
hp
>
0
:
info3
=
enemy
.
name
+
"还剩下"
+
str
(
enemy
.
hp
)
+
"血量"
info
=
info1
+
info2
+
info3
print
(
info
)
else
:
info3
=
enemy
.
name
+
"阵亡,游戏结束"
info
=
info1
+
info2
+
info3
print
(
info
)
exit
()
class
Player
(
Hero
):
def
__init__
(
self
,
name
,
hero_type
):
super
(
Player
,
self
)
.
__init__
(
name
)
self
.
hp
=
100
self
.
attack
=
4
self
.
hero_type
=
hero_type
print
(
"角色"
,
self
.
name
+
"创建成功,英雄类名为:"
,
self
.
hero_type
)
print
(
"当前等级、血量、攻击力分别为:"
,
self
.
level
,
self
.
hp
,
self
.
attack
)
libai
=
Player
(
"李白"
,
"打野"
)
kai
=
Hero
(
"凯"
)
# player = Player("李白")
# print("玩家的血量为:",player.hp)
# print("玩家的攻击力为:",player.attack)
7.py
0 → 100644
View file @
dcea2c65
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
3
self
.
name
=
name
self
.
hp
=
hp
self
.
attack
=
attack
class
Player
(
Hero
)
:
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
10000
self
.
attack
=
4
self
.
name
=
name
player
=
Player
(
"后裔"
)
print
(
"玩家的血量为:"
,
player
.
hp
)
print
(
"玩家的攻击力为:"
,
player
.
attack
)
# def combat(self,enemy):
# info1 = self.name+"对"+enemy.name+"发起攻击,"
# info2 = "造成" +str(self.attack)+"点伤害,"
# enemy.hp -= self.attack
# if enemy.hp > 0:
# info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
# info = info1+info2+info3
# print(info)
# else:
# info3 = enemy.name+"阵亡,游戏结束"
# info = info1+info2+info3
# print(info)
# exit()
# libai = Hero("李白")
# kai = Hero("凯")
# libai.combat(kai)
\ No newline at end of file
8.py
0 → 100644
View file @
dcea2c65
class
Dog
:
def
__init__
(
self
):
self
.
footnum
=
4
self
.
eyenum
=
2
self
.
head
=
1
self
.
earnum
=
2
self
.
skin
=
"white"
def
run
(
self
):
print
(
"小猫飞快地跑起来"
)
class
Husky
(
Dog
):
def
__init__
(
self
):
super
()
.
__init__
()
self
.
skin
=
"black"
coco
=
Husky
()
print
(
coco
.
skin
)
\ No newline at end of file
diy.py
View file @
dcea2c65
with
open
(
r'c:\Users\ThinkPad\Documents\lesson13-1\sales_list.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
file1
:
a
=
file1
.
readlines
()
# print(a)
final_sum
=
[]
for
i
in
a
:
data
=
i
.
split
()
sum
=
0
for
sales
in
data
[
1
:]:
sum
+=
int
(
sales
)
result
=
data
[
0
]
+
str
(
sum
)
+
"
\n
"
final_sum
.
append
(
result
)
#print(result)
with
open
(
r'c:\Users\ThinkPad\Documents\lesson13-1\new_sales_list.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
file1
:
file1
.
writelines
(
final_sum
)
new_sales_list.txt
View file @
dcea2c65
悟空348
class Dog:
诺依380
def __init__(self):
小贝182
self.footnum = 4
李丽201
self.eyenum = 2
宋扬107
self.head = 1
王明245
self.earnum = 2
李强164
self.skin = "white"
孙小白222
苏琪137
def run(self):
刘若若147
print("小猫飞快地跑起来")
刘阳226
王胜男123
class Husky(Dog):
王娇131
def __init__(self):
super(). __init__()
self.skin = "black"
coco = Husky()
print(coco.skin)
\ No newline at end of file
sales_list.txt
View file @
dcea2c65
悟空 12 15 11 12 11 12 13 21 27 12 15 30 22 26 15 12 21 23 27 11
class Dog:
诺依 21 29 15 21 21 21 29 30 12 13 12 12 24 52 27 26 15
def __init__(self):
小贝 29 11 11 15 13 15 13 11 11 29 13 11
self.footnum = 4
李丽 13 15 20 15 15 11 17 20 20 11 12 12 20
self.eyenum = 2
宋扬 11 11 11 11 15 17 11 20
self.head = 1
王明 30 27 26 24 29 12 15 11 22 26 23
self.earnum = 2
李强 12 12 11 15 11 13 25 26 11 13 15
self.skin = "white"
孙小白 25 26 12 15 27 30 48 39
苏琪 15 11 15 15 30 13 27 11
def run(self):
刘若若 11 11 13 11 20 15 13 29 24
print("小猫飞快地跑起来")
刘阳 11 15 22 11 23 26 22 15 17 52 12
王胜男 27 15 15 26 13 12 15
class Husky(Dog):
王娇 12 11 12 12 15 35 23 11
def __init__(self):
\ No newline at end of file
super(). __init__()
self.skin = "black"
coco = Husky()
print(coco.skin)
\ 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