Commit 00afa14f by BellCodeEditor

auto save

parent 98f24605
Showing with 66 additions and 11 deletions
#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
# 这是悟空为花果山小猴做臂力测试的程序代码
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)
# 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=
print(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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment