Commit b7e13869 by BellCodeEditor

auto save

parent d18404cd
import turtle
t=turtle.Pen()
n=1
for j in range(12):
if n%2==0:
t.pencolor('green')
else:
t.pencolor('blue')
for i in range(3):
t.forward(50)
t.right(120)
n=n+1
t.penup()
t.forward(50)
t.right(360/12)
t.pendown()
turtle.done()
\ No newline at end of file
class Hero:
def __init__(self,name):
self.level=1
self.hp=30
self.attack=20
self.name=name
def combat(self,enemy):
info1 = self.name + '对' + enemy.name +'发起进攻'
info2 = '对' + enemy.name + '造成' + str(self.attack) + '点伤害'
enemy.hp=enemy.hp-self.attack
if enemy.hp>0:
info3 = enemy.name + '还剩下' + str(enemy.hp)
info=info1+info2+info3
print(info)
else:
info3 = '您已阵亡'
info=info1+info2+info3
print(info)
exit()
class hero(Hero):
def __init__(self,name):
super().__init__(name)
self.hp=100
self.attack=10
# yase = Hero('亚瑟')
# houyi = Hero('后羿')
# yase.combat(houyi)
yase = hero('亚瑟')
print(yase.hp,yase.attack)
\ No newline at end of file
...@@ -3,7 +3,6 @@ class Hero(): ...@@ -3,7 +3,6 @@ class Hero():
self.attack=250 self.attack=250
self.hp=30 self.hp=30
self.name=name self.name=name
def combat(self,emeny): def combat(self,emeny):
emeny.hp=emeny.hp-self.attack emeny.hp=emeny.hp-self.attack
info1=self.name+'对'+emeny.name+'发起攻击' info1=self.name+'对'+emeny.name+'发起攻击'
......
import turtle
t = turtle.Pen()
t.pencolor('blue')
t.goto(0,0)
for i in range(6):
for j in range(6):
t.forward(100)
t.right(60)
t.right(60)
turtle.done()
\ No newline at end of file
def number():
list1 = []
for i in range(1,1001):
sum=0
for j in range(1,i):
if i%j == 0:
sum += j
if sum == i:
list1.append(i)
print(list1)
number()
\ No newline at end of file
a = input("请输入一个数")
if a.isdigit():
a = str(a)
for i in range(int(len(a)/2)):
if a[i] != a[len(a)-i-1]:
print(a,"不是回文数")
break
else:
print(a,'是回文数')
import turtle
import random
t=turtle.Pen()
turtle.setup(width=800,height=600)
t.speed(7)
t.pensize(5)
t.pencolor('black')
t.fillcolor('yellow')
for i in range(5):
x= random.randint(-400,240)
y= random.randint(-150,150)
x1 = random.randint(10,150)
t.penup()
t.goto(x,y)
t.pendown()
t.begin_fill()
for j in range(5):
t.forward(x1)
t.right(144)
t.end_fill()
turtle.done()
\ No newline at end of file
number=input('请输入数字:')
print(number)
number_list=number.split(',')
#print(number_list)
new_list=[]
for i in number_list:
new_list.append(eval(i))
print(len(new_list))
print(min(new_list))
list1=[]
list1 = sorted(new_list)
#print(len(list1))
for i in range(len(list1)):
if i==len(list1)-1:
print(list1[i])
else:
print(list1[i],end=',')
#['A','B','C']
list2=[]
for i in range(65,91):
list2.append(chr(i))
print(list2)
for i in new_list:
if 1<=i<=26:
print(list2[i-1],end=' ')
else:
print('*')
\ No newline at end of file
import turtle
t=turtle.Pen()
#t.penup()
t.penup()
t.goto(0,-200)
t.pendown()
t.fillcolor('green')
t.begin_fill()
t.forward(300)
t.left(90)
t.circle(150,180)
t.end_fill()
t.penup()
t.left(180)
t.forward(150)
t.pendown()
t.right(90)
t.pencolor('red')
t.fillcolor('yellow')
t.begin_fill()
for i in range(3):
t.forward(300)
t.left(120)
t.end_fill()
turtle.done()
\ No newline at end of file
for i in range(0,100 // 5 +1):
for j in range(0,100//3+1):
c=100-i-j
if i*5+j*3+c*(1/3)==100:
print('公鸡{}只,母鸡{}只,小鸡{}只'.format(i,j,c))
\ No newline at end of file
str=input('请输入五个数:')
str=str.split(',')
nums=[]
for i in str:
nums.append(eval(i))
print(max(nums))
print(min(nums))
sum=0
for i in range(len(nums)):
sum+=nums[i]
sum=sum/len(nums)
print('{:.1f}'.format(sum))
\ No newline at end of file
sum1=''
for i in range(3):
a=input('请输入{}行英文文字:'.format(i+1))
sum1=sum1+a
#print(sum1)
sum2=sum1
sum1=sum1.upper()
sum2=set(sum2.upper())
sum2=sorted(sum2)
list1=[]
for i in sum2:
if i.isalpha():
print(i,end=' ')
list1.append(sum1.count(i))
print()
for i in list1:
print(i,end=' ')
dic=dict()
s=set()
s='helloworld'
d3=list(s)
for x in d3:
d3[x]=s.count(x)
print(d3)
\ No newline at end of file
flag=input('请输入图形')
num=int(input('请输入循环的次数'))
print((num-1)*' '+flag)
for i in range(num-2):
for j in range(num-i-2):
print(" ",end='')
print(flag,end='')
for j in range(i*2+1):
print(" ",end='')
print(flag)
print((num*2-1)*flag)
import turtle
t=turtle.Pen()
t.pencolor('black')
t.left(90)
for i in range(10):
for i in range(5):
t.right(72)
t.forward(100)
t.right(36)
turtle.done()
list1=[]
for j in range(100,1000):
num=str(j)
sum=0
for i in num:
num1=int(i)
sum=(num1**3)+sum
if sum == j:
list1.append(num)
print(list1)
\ No newline at end of file
def result(score):
if score >= 90 :
grade='A'
else:
if score<=89 and score >= 60:
grade='B'
else:
grade='C'
print(grade)
result(99)
\ No newline at end of file
def result(round1,num):
round1 = int(input('请输入要循环的次数'))
num = input('请输入要想加的数字)
sum = 0
for i in range(round1):
\ No newline at end of file
u = 2.0
d = 1.0
s = 0.0
for i in range(0,20):
s = s+u/d
u = u+d
d = u-d
print (s)
\ No newline at end of file
import turtle
t=turtle.Pen()
t.pensize(5)
turtle.bgcolor('white')
t.pencolor('red')
for i in range(15):
for i in range(10):
t.forward(50)
t.right(36)
t.right(24)
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