Commit 354a0073 by BellCodeEditor

auto save

parent 1932fe6c
str1='本节课我们学习加密'
str2='用python进行'
str1=list(str1)
str1.insert(-4,str2)
str1=''.join(str1)
print(str1)
\ No newline at end of file
str1='bellcode'
print(str1[-4:])
\ No newline at end of file
import random
sum1=0
sum2=0
sum3=0
for i in range(3000):
x=random.randint(8,1000)
if x==8:
sum1+=1
if x==9:
sum2+=1
if x==10:
sum3+=1
print('8'+'有'+str(sum1)+'次','9'+'有'+str(sum2)+'次','10'+'有'+str(sum3)+'次')
\ No newline at end of file
text='Hello work'
for i in text:
print(i,end='')
print()
for i in range(len(text)):
print(text[i],end='')
\ No newline at end of file
......@@ -22,16 +22,30 @@ index = 0
y = 400
jumpState = "runing"
t = 30
bg_x = 0
road_x = 0
obstacle = random.choice([bush, stone, cacti])
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
time=0
# #obstacle = random.choice([bush, stone, cacti])
# rect = obstacle.get_rect()
# rect.x = 1000
# rect.y = 500 - rect.height
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
super().__init__()
self
self.image = random.choice([image1,image2,image3])
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
class Player(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__()
self.image=image
self.rect=self.image.get_rect()
self.rect.x=150
self.rect.y=400
block_list=pygame.sprite.Group()
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
......@@ -43,19 +57,20 @@ while True:
road_x-=8
if road_x<-1000:
road_x=0
if jumpState == "up": # 起跳状态
if t > 0:
y -= t
t -= 2
else:
jumpState = "down"
if jumpState == "down": # 降落状态
if t <= 30:
y += t
t += 2
else:
jumpState = "runing"
t =30
if gamesate=='True':
if jumpState == "up": # 起跳状态
if t > 0:
y -= t
t -= 2
else:
jumpState = "down"
if jumpState == "down": # 降落状态
if t <= 30:
y += t
t += 2
else:
jumpState = "runing"
t =30
# 悟空造型
wukong = hero[index]
......@@ -63,19 +78,28 @@ while True:
index += 1
if index >= 5:
index = 0
# 将背景图画上去
screen.blit(background, (0, 0)) # 远处背景
# 将背景图画上去WWWWWAASDD
screen.blit(background, (0, 0)) # 远处背景DJDJ FGYJRNFJUJKRHYJGGYFDGYDB
screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
if rect.x <= 0-rect.width: # 障碍物消失
# 创建障碍物对象
obstacle = random.choice([bush,stone,cacti])
rect = obstacle.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
rect.x -= 8
screen.blit(obstacle, (rect.x, rect.y))
time+=1
if time>=60:
time=0
n=random.randint(0,50)
if n>20:
obstacle=Block(bush,stone,cacti)
block_list.add(obstacle)
for sprite in block_list:
sprite.rect.x -=8
screen.blit(sprite.image,( sprite.rect.x,sprite.rect.y))
if sprite.rect.x <= 0-obstacle.rect.width:
sprite.kill()
#obstacle = Block(bush,stone,cacti)
#rect = obstacle.get_rect()
#rect.x = 1000
#rect.y = 500 - rect.height
# rect.x -= 8
# screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
str1=['p','y','t','h','o','n']
str2='',join(str1)
print(str2)
\ No newline at end of file
import random
key1='周末一起去欢乐海岸'
text1='roswmzhx'
text1=list(text1)
for i in range(10):
a=random.randint(0,len(text1))
key1=list(key1)
key1.insert(a,text1[a])
print(key1)
key2=''.join(key1)
print(key2)
\ 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