Commit e291bf53 by BellCodeEditor

auto save

parent 2eb6206f
Showing with 93 additions and 18 deletions
class Zhanshi:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def levelup(self):
self.level=self.level+1
self.hp=self.hp+100
self.attack=self.attack+3
yase=Zhanshi("亚瑟",300,40)
yase.levelup()
yase.levelup()
yase.levelup()
yase.levelup()
yase.levelup()
yase.levelup()
yase.levelup()
yase.levelup()
yase.levelup()
yase.levelup()
print("英雄等级是:",yase.level)
print("英雄血量是:",yase.hp)
print("英雄攻击是:",yase.attack)
class Fashishi:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def levelup(self):
self.level=self.level+1
self.hp=self.hp+30
self.attack=self.attack+8
diaochan=Fashishi("貂蝉",200,60)
diaochan.levelup()
diaochan.levelup()
diaochan.levelup()
diaochan.levelup()
diaochan.levelup()
diaochan.levelup()
diaochan.levelup()
diaochan.levelup()
diaochan.levelup()
diaochan.levelup()
print("英雄等级是:",diaochan.level)
print("英雄血量是:",diaochan.hp)
print("英雄攻击是:",diaochan.attack)
a={"张":{"语文":120,"数学":135,"英语":130},"吴":{"语文":127,"数学":137,"英语":143},"廖":{"语文":120,"数学":130,"英语":130},"钟":{"语文":100,"数学":100,"英语":100}}
while True:
i=0
b=input("请输入你的名字:")
if b in a:
print(a[b])
if b not in a:
i=i+1
print("查无此人")
if i==3:
exit()
if b=="q":
exit()
\ No newline at end of file
# 报菜名
# 悟空和诺依到了一家特色餐馆,这家餐馆最大的特色就是有个自动报菜名机器人
# 通常它会自动说出今天的前菜有哪些汤有哪些主菜有哪些等等~
# 可是今儿它有些bug产生的结果很奇怪,你可以检查出来么?
today_menu={'前菜':{'熏鲢鱼':20,'生蚝':20,'面包':10},
'汤':{'玉米浓汤':15,'蔬菜汤':15,'海鲜汤':15},
'主菜':{'鱼':40,'虾':30,'蟹':20,'贝壳类':20},
'间菜':{'牛扒':25,'煨菜':25,'肉排':30},
"烧烤和沙拉":{'需要':15,'不需要':0},
'甜品':{'可丽露':20,'优格吐司':15,'蓝莓松饼':20}
}
for k,v in today_menu.items():
print('今日' + k + '有:')
for i,j in v.items():
print(i,end=' ') #依次告诉客人今天的各类菜有哪些选择
print()
\ No newline at end of file
with open(r"c:\Users\Administrator\Desktop\4343.txt","r",encoding="gbk")as a:
b=a.readlines()
final_sum=[]
for i in b:
c=i.split()
sum=0
for j in c[1:]:
sum=sum+int(j)
result=c[0]+str(sum)+'\n'
final_sum.append(result)
with open(r"c:\Users\Administrator\Desktop\4343.txt","w",encoding="gbk")as a:
d=a.writelines(final_sum)
\ No newline at end of file
a=open(r"c:\Users\Administrator\Desktop\xj.txt","w",encoding="utf-8")
a.write("小兰12本\n")
a.close()
with open(r"c:\Users\Administrator\Desktop\xj.txt","a",encoding="utf-8")as a:
a.write("小明15本\n")
a.write("小红17本\n")
b=""
with open(r"c:\Users\Administrator\Desktop\xj.txt","r",encoding="utf-8")as a:
for i in a:
if"小明:15本" in i:
i=i.replace("小明:15本","小明:16本")
b=b+i
print(b)
with open(r"c:\Users\Administrator\Desktop\xj.txt","r",encoding="utf-8")as a:
a.write(b)
\ 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