Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson8-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
00afa14f
authored
Jul 13, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
98f24605
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
11 deletions
class.py
diy1.py
class.py
0 → 100644
View file @
00afa14f
#fw开始界面
hero
=
{
'1'
:
'青铜'
,
'2'
:
'白银'
,
'3'
:
'王者'
}
print
(
"="
*
4
+
"游戏角色管理系统"
+
"="
*
4
)
print
(
"1.增加角色和段位"
)
print
(
"2.删除角色"
)
print
(
"3.修改段位"
)
print
(
"4.查询所有角色"
)
print
(
"5.根据角色查找段位"
)
print
(
"6.退出"
)
print
(
"="
*
24
)
#正片开始
while
True
:
a
=
input
(
"请输入你想要进行的操作:"
)
if
int
(
a
)
<
1
or
int
(
a
)
>
6
:
print
(
"请输入1-6的数字"
)
elif
int
(
a
)
==
1
:
b
=
input
(
"请输入你想增加的角色:"
)
if
b
in
hero
.
keys
():
print
(
"已有该角色请换一个"
)
continue
c
=
input
(
"段位:"
)
hero
[
b
]
=
c
print
(
"已加入"
)
print
(
hero
)
print
(
"="
*
24
)
elif
int
(
a
)
==
2
:
d
=
input
(
"请输入你想删除的角色:"
)
del
hero
[
d
]
print
(
"已删除"
)
print
(
hero
)
elif
int
(
a
)
==
3
:
e
=
input
(
"请输入你想要更换段位的角色:"
)
f
=
input
(
"段位"
)
hero
[
e
]
=
f
print
(
"已更换"
)
print
(
hero
)
elif
int
(
a
)
==
4
:
for
key
,
value
in
hero
.
items
():
print
(
key
,
value
)
elif
int
(
a
)
==
5
:
g
=
input
(
"请输入你想要查找的角色:"
)
for
g
in
hero
.
keys
():
if
g
in
hero
:
print
(
g
,
hero
[
g
])
else
:
print
(
"抱歉没有这个角色"
)
continue
elif
int
(
a
)
==
6
:
exit
()
\ No newline at end of file
diy1.py
View file @
00afa14f
# 这是悟空为花果山小猴做臂力测试的程序代码
# 这是悟空为花果山小猴做臂力测试的程序代码
name
=
input
(
'你叫啥名啊?'
)
#
name=input('你叫啥名啊?')
power
=
int
(
input
(
'你臂力多少啊?'
))
#
power=int(input('你臂力多少啊?'))
list_hero
=
[
'猴三'
,
10
,
'猴一'
,
21
,
'猴五'
,
22
,
'猴队长'
,
29
,
'猴七'
,
30
]
#
list_hero=['猴三',10,'猴一',21,'猴五',22,'猴队长',29,'猴七',30]
for
i
in
range
(
len
(
list_hero
)):
#
for i in range(len(list_hero)):
if
i
%
2
==
1
and
list_hero
[
i
]
>=
power
:
#
if i%2==1 and list_hero[i]>=power:
list_hero
.
insert
(
i
-
1
,
name
)
#
list_hero.insert(i-1,name)
list_hero
.
insert
(
i
,
power
)
#
list_hero.insert(i,power)
break
#
break
print
(
list_hero
)
#
print(list_hero)
# 请注释掉上面的代码,并在下一行创建一个名为dict_hero的字典
# 请注释掉上面的代码,并在下一行创建一个名为dict_hero的字典
dict_hero
=
dict_hero
=
{
'可乐'
:
10
,
'迈动'
:
11
,
'乐事'
:
15
,
'旺仔牛奶'
:
5
,
'真果粒'
:
9
}
print
(
dict_hero
)
k
=
input
(
'你想买什么?'
)
if
k
in
dict_hero
:
print
(
'叮咚~您买的东西的价钱是'
,
str
(
dict_hero
[
k
]))
else
:
print
(
'抱歉!您要的东西百货商店暂时缺货,敬请期待!'
)
\ 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