Commit 7003c644 by BellCodeEditor

auto save

parent beb166ed
import turtle #导入包
pen = turtle.Pen() #创建画笔
pen.fillcolor("red")#设置填充颜色
pen.begin_fill()#开始填充颜色
for i in range(5):#for循环
pen.forward(200)#移动到
pen.right(144)#向右旋转
pen.end_fill()#结束填充
pen.hideturtle()#隐藏画笔
turtle.done()#程序结束时保存画布
import random #导入随机数
list=['剪刀','石头','布']
player=input("玩家请出拳:(剪刀/石头/布)")
print("玩家出的是:",player)
computer=random.choice(list)
print("电脑出的是:",computer)
if player in list:
if player==computer:
print('平局')
elif player=='石头' and computer=='剪刀':
print('恭喜,你赢了!')
elif player=='剪刀' and computer=='布':
print('恭喜,你赢了!')
elif player=='布' and computer=='石头':
print('恭喜,你赢了!')
else:
print('你输了!')
else:
print("输入错误!")
import turtle
screen=turtle.Screen()
screen.bgcolor('light blue')
len=screen.textinput('100','100')
len=int(len)
pen=turtle.Pen()
pen.penup()
pen.goto(-200,-200)
pen.pendown()
pen.write('你好\n诺依\n我是悟空',font=('Times',20,'normal'))
pen.hideturtle()
pen.penup()
pen.goto(50,10)
pen.pendown()
pen.pensize(5)
pen.pencolor('red')
pen.left(45)
pen.forward(2*len)
pen.circle(len,180)
pen.right(90)
pen.circle(len,180)
pen.forward(2*len)
turtle.done()
\ No newline at end of file
i=3
username='python'
password='1234'
while True:
if i>0:
name=input("请输入账号:")
pwd=input("请输入密码:")
i-=1
if name==username and pwd==password:
print("登录成功")
break
elif name!=username:
print("账号错误")
print("您还剩"+str(i)+"次机会,请重新输入")
elif pwd!=password:
print("密码错误")
print("您还剩"+str(i)+"次机会,请重新输入")
else:
print("您的账号已被锁定")
exit()
print("欢迎来到贝尔编程")
\ No newline at end of file
for i in range(1,10):
for j in range(1,i+1):
print(j,'*',i,'=',(j*i),end='\t')
print()
\ No newline at end of file
...@@ -11,7 +11,7 @@ class Hero(object): ...@@ -11,7 +11,7 @@ class Hero(object):
self.hp+=55 self.hp+=55
if self.hp>self.max_hp: if self.hp>self.max_hp:
self.hp=self.max_hp self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:", 55,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击 def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻," info1 = self.name+"对"+enemy.name+"发起进攻,"
...@@ -39,12 +39,12 @@ class Player(Hero): ...@@ -39,12 +39,12 @@ class Player(Hero):
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack) print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
print('-'*30) print('-'*30)
print(' 战斗开始') print(' 战斗开始')
def cure(self): def cure(self):
c=random.randint(35,50) c=random.randint(35,50)
self.hp+=c self.hp+=c
if self.hp>self.max_hp: if self.hp>self.max_hp:
self.hp=self.max_hp self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp)
houyi = Player("射手", "后羿") houyi = Player("射手", "后羿")
yase = Hero("垭瑟") yase = Hero("垭瑟")
......
import random
class Hero(object):
def __init__(self, name):
self.name = name #名字
self.level = 1 #等级
self.hp = 250 #血量
self.attack = 40 #攻击力
self.max_hp=self.hp #最大生命值
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)
print('你干嘛啊~~')
exit()#退出程序
def cure(self):#治疗
self.hp+=55
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:", 55,",目前的血量为:",self.hp)
class Player(Hero):#继承类
def __init__(self,name,hero_type):
super().__init__(name)
self.hp = 200
self.attack = 50
self.max_hp = self.hp
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
print('-'*30)
print(' 战斗开始')
def cure(self):#角色治疗术
c=random.randint(35,50)
self.hp+=c
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp)
houyi = Player("后羿","射手")
yase = Hero("垭瑟")
while True:
print('-'*30)
a=input("请选择技能:1攻击/2治疗")
if int(a)==1:
houyi.combat(yase)
elif int(a)==2:
houyi.cure()
elif a=='q':
break
else:
print("请重新输入!")
continue
b=random.randint(1,3)#亚瑟 随机释放技能
if b==3:
yase.cure() #治疗
else:
yase.combat(houyi) #攻击
\ No newline at end of file
long=int(input("请输入长方形的长:"))
k=int(input("请输入长方形的宽:"))
zhouchang=(long+k)*2
mianji=long*k
print("该长方形的周长是:",zhouchang)
print("该长方形的面积是:",mianji)
\ No newline at end of file
import turtle
pen=turtle.Pen()
# screen=turtle.Screen()
# screen.bgcolor("black")
pen.fillcolor("black")
pen.penup()
pen.goto(-150,-150)
pen.pendown()
for e in range(1,5):
pen.fillcolor("black")
if e==2:
pen.forward(100)
pen.begin_fill()
elif e==3:
pen.forward(100)
pen.left(90)
pen.forward(100)
elif e==4:
pen.forward(100)
pen.left(90)
pen.forward(100)
pen.begin_fill()
for i in range(1,5):
pen.forward(100)
pen.left(90)
pen.end_fill()
pen.hideturtle()
turtle.done()
\ 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