deffibs(s,n):for i inrange(0,n-2):
s+=[s[-1]+s[-2]]print(s1)
s1=[0,1]
n=int(input("plz input a number"))
fibs(s1,n)#w我真的弄不懂全局变量和局部变量……
输出1000~10000的全部回文数
defhw(s):
s=str(s)iflen(s)==1or s=="":returnTrueelse:if s[0]!=s[-1]:returnFalseelse:return hw(s[1:-1])for i inrange(1000,10000):if hw(i):print(i,end=" ")
猜数游戏
from random import*
n=randint(1,100)
count=0
x=int(input("输入猜测数:"))while x!=n:if x<n:print("小了")if x>n:print("大了")
count+=1if count>4:print("已经猜测5次,游戏结束")break
x=int(input("输入猜测数:"))if x==n and count<=4:print("一共猜了",count,"次","恭喜你猜对了!")