Lv.1
在 【Python作品分享】肥不垃圾 中回复
import functools
@functools.lru_cache()
def fib(x):
if x<=2:
return 1
return fib(x-1)+fib(x-2)
这个数据一大就慢了,改进了下
2019-10-13T12:20:01 点赞:0
在 【Python作品分享】计时器【作业帖】 中回复
错了,
__repr__ = __str__
应该为
def __repr__(self):
return Mytimer.__str__(self)
2020-02-21T18:04:08 点赞:0
在 遇到一道难题,求大佬帮忙!!! 中回复
a,b=list(map(int,input().split())) for i in range(a*100,a*100+100): if i%b==0: print(i)
2020-04-06T18:52:32 点赞:0
在 遇到一道难题,求大佬帮忙!!! 中回复
a,b=list(map(int,input().split()))
for i in range(a*100,a*100+100):
if i%b==0:
print(i)2020-04-06T18:52:42 点赞:0
在 遇到难题,求大佬解答!!! 中回复
#瞎写的,可能不简洁
cnt=-1
max=-1
ch=' '
st=input()
for c in st:
cnt=st.count(c)
if cnt>max:
max=cnt
ch=c
print(c)
2020-04-14T19:36:46 点赞:0
在 Py代码猜猜看05 中回复
一、
import turtle
p=turtle.Pen()
p.speed(0)
for _ in range(360):
p.forward(1)
p.right(1)
2:
ABC
a
ABC
a
ABC
a
ABC
a
==报错==
3:
会停止运行
2020-04-18T15:51:53 点赞:0
在 一个想法(凑字数) 中回复
import pygame
from pygame.locals import *
from sys import exit
import copy
SIZE = 20
pygame.init()
screen = pygame.display.set_mode((SIZE*32,SIZE*32), 0, 32)
game = [[0 for i in range(SIZE)] for j in range(SIZE)]
game2 = [[0 for i in range(SIZE)] for j in range(SIZE)]
def show():
for i in range(SIZE):
for j in range(SIZE):
if not game[i][j]:
pygame.draw.rect(screen,(200,200,200),Rect(j*32,i*32,32,32))
else:
pygame.draw.rect(screen, (0,0,255), Rect(j * 32, i * 32, 32, 32))
def count(x,y):
cnt=0
for i in range(-1,2):
for j in range(-1,2):
if not i and not j:
continue
if is_legit(x+i,y+j):
if game[x+i][y+j]:cnt+=1;
return cnt
def is_legit(x,y):
return 0<=x<SIZE and 0<=y<SIZE
def cal():
global game,game2
for i in range(SIZE):
for j in range(SIZE):
if count(i,j)==2:
game2[i][j]=game[i][j]
elif count(i,j)==3:
game2[i][j] = 1
else:
game2[i][j] = 0
# if(count(i,j)):
# print("count:{},{}={} game:{}".format(i,j,count(i,j),game2[i][j]))
game=copy.deepcopy(game2)
# print("==========")
setting = True
while True:
for event in pygame.event.get():
if event.type == QUIT:
exit()
if event.type == MOUSEBUTTONDOWN:
a,b,c=pygame.mouse.get_pressed()
if c:
setting=False
continue
if setting:
ex, ey = event.pos
game[ey//32][ex//32] = not game[ey//32][ex//32]
else:
cal()
show()
pygame.display.update()2020-04-18T21:05:55 点赞:0
在 PY代码做做看 中回复
喵机:
print(2**2179381273987128937128973918)
或
import random
while(1):
with open(str(random.randint(0,1203991820),"w") as f:
f.write("sakjdhasjdhasjkhdkashdj\njshdkasjdhaskdhaskjhdkasjhdjkash\nsajdhaskdhasjkdhasjkdhaskhdjkashdajkshdjkahsdj")2020-04-20T15:11:55 点赞:0