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
b2024c70
authored
Jul 14, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
00afa14f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
68 deletions
class.py
diy1.py
class.py
View file @
b2024c70
#fw开始界面
"""dict_hero={'猴三':10,'猴一':21,'猴五':22,'猴队长':29,'猴七':10}
hero
=
{
'1'
:
'青铜'
,
'2'
:
'白银'
,
'3'
:
'王者'
}
print(dict_hero)
print
(
"="
*
4
+
"游戏角色管理系统"
+
"="
*
4
)
print
(
"1.增加角色和段位"
)
dict_hero['猴队长']=66
print
(
"2.删除角色"
)
dict_hero['猴一']=29
print
(
"3.修改段位"
)
print(dict_hero)
print
(
"4.查询所有角色"
)
print
(
"5.根据角色查找段位"
)
dict_hero['猴哥']=999
print
(
"6.退出"
)
dict_hero['唐憎']=888
print
(
"="
*
24
)
print(diifct_hero)"""
#正片开始
dict
=
{
'可口可乐'
:
3
,
'旺仔牛奶'
:
4
,
'农夫山泉'
:
1
,
'辣条'
:
3
,
'巴西烤肉'
:
2
,
'果冻'
:
4
,
'乐事'
:
5
,
'奥利奥'
:
10
,
'巧克力'
:
6
,}
while
True
:
k
=
input
(
"你想要什么?"
)
a
=
input
(
"请输入你想要进行的操作:"
)
if
k
in
dict
:
if
int
(
a
)
<
1
or
int
(
a
)
>
6
:
print
(
"你想要的"
+
k
+
"需要"
,
dict
[
k
],
"元"
)
print
(
"请输入1-6的数字"
)
else
:
elif
int
(
a
)
==
1
:
print
(
"没有"
)
b
=
input
(
"请输入你想增加的角色:"
)
\ No newline at end of file
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
deleted
100644 → 0
View file @
00afa14f
# 这是悟空为花果山小猴做臂力测试的程序代码
# name=input('你叫啥名啊?')
# power=int(input('你臂力多少啊?'))
# list_hero=['猴三',10,'猴一',21,'猴五',22,'猴队长',29,'猴七',30]
# for i in range(len(list_hero)):
# if i%2==1 and list_hero[i]>=power:
# list_hero.insert(i-1,name)
# list_hero.insert(i,power)
# break
# print(list_hero)
# 请注释掉上面的代码,并在下一行创建一个名为dict_hero的字典
dict_hero
=
{
'可乐'
:
10
,
'迈动'
:
11
,
'乐事'
:
15
,
'旺仔牛奶'
:
5
,
'真果粒'
:
9
}
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