Commit eb4a167c by BellCodeEditor

auto save

parent b225c7b6
Showing with 21 additions and 6 deletions
r=float(input('圆的半径:'))
e=3.1456
print("圆的直径是:%.2f" % (2*r))
print("圆的周长是:%.2f" % (2*e*r))
print('圆的面积是:',round(r*r*e,2))
\ No newline at end of file
#创建一个英雄类
class Hero:
def __init__(self):
def __init__(self,name,hp,attack):
self.level=1 #等级
self.hp=300 #血量
self.attack=25 #攻击力
self.name=name #名字
self.hp=hp #血量
self.attack=attack #攻击力
def upgrade(self):
self.level+=1
self.hp+=50
self.attack+=5
#实例化对象
yase=Hero()
houyi=Hero()
yase=Hero('亚瑟',300,25)
houyi=Hero('后羿',240,40)
yase.upgrade()
houyi.upgrade()
houyi.upgrade()
print('亚瑟的血量是',yase.hp)
print('后羿的血量是',houyi.hp)
\ 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