Commit 14197474 by BellCodeEditor

auto save

parent 0cc37ad4
class Dog:
def __init__(self,color,name):
self.tui = 4
self.yan = 2
self.color = color
self.name = name
wangcai = Dog("red","旺财")
print(wangcai.name)
\ No newline at end of file
class Cat:
def __init__(self,type,color,price):
self.footNum = 4
self.type = type
self.color = color
self.price = price
def wzx(self):
print("您购买的小猫咪,价格为"+str(self.price)+"元")
shamao = Cat("shazi","red",99999999)
shamao.wzx()
\ No newline at end of file
a = float(input("请输入体重:"))
b = float(input("请输入身高:"))
BMI = a/(b*b)
if BMI<=18.4:
print("偏瘦")
elif BMI>=18.5 and BMI<=23.9:
print("正常")
elif BMI>=24.0 and BMI<=27.9:
print("过重")
else:
print("肥胖")
\ No newline at end of file
class Hero:
def __init__(self,name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
def combat(self,enemy):
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
enemy.hp = self.attack
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1+info2+info3
print(info)
else:
info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3
print(info)
exit()
yase = Hero("亚瑟")
houyi = Hero("后羿")
yase.combat(houyi)
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