import turtle as t
import random
def draw_f(x):
#F0=1
#F1=1
#Fn=F(n-1)+F(n-2)
f_list=[]
for i in range(x):
if i==0:
f_list.append(1)
elif i==1:
f_list.append(1)
else:
f_list.append(f_list[i-1]+f_list[i-2])
#像素比例
f0=50
#设置画笔属性
t.pensize(5)
t.color("green")
t.penup()
t.home()
t.pendown()
for i in range(0,len(f_list)):
t.speed(1)
t.pendown()
#绘制矩形
if i==0:
fill_color="green"
else:
fill_color=(random.random(),random.random(),random.random())
print(fill_color)
t.fillcolor(fill_color)
t.begin_fill()
for j in range(4):
t.fd(f_list[i]*f0)
t.left(90)
"""
t.fd(
斐波那契平方和
最新推荐文章于 2024-09-09 00:00:00 发布
本文探讨了斐波那契数列中各数的平方和,通过Python编程展示了计算过程,并得出相应的图形结果。
摘要由CSDN通过智能技术生成