時鐘的打印
本文免費(fèi)直播課程分享鏈接:https://ke.qq.com/course/397896?flowToken=1009460
有需要學(xué)習(xí)提升的寶寶可以進(jìn)去免費(fèi)報名一下
每天分享一些好完的技術(shù)和主流的項目
打印時鐘:
import turtle
def draw_spiral(t, n, length=3, a=0.1, b=0.0002):
#Draws an Archimedian spiral starting at the origin
theta = 0.0
for i in range(n):
t.fd(length)
dtheta = 1 / (a + b * theta)
t.lt(dtheta)
theta += dtheta
#create the world and bob
bob = turtle.Turtle()
draw_spiral(bob, n=1000)
turtle.mainloop()
花的打印
打印花:
import turtle
def polyline(t, n, length, angle):
#Draws n line segments
for i in range(n):
t.fd(length)
t.lt(angle)
def arc(t, r, angle):
#Draws an arc with given radius and angle
arc_length = 2 * math.pi * r * abs(angle) / 360
n = int(arc_length / 4) + 3
step_length = arc_length / n
step_angle = float(angle) / n
t.lt(step_angle/2)
polyline(t, n, step_length, step_angle)
t.rt(step_angle/2)
def petal(t, r, angle):
#Draws a petal using two arcs.
for i in range(2):
arc(t, r, angle)
t.lt(180 - angle)
def flower(t, n, r, angle):
#Draws a flower with n petals
for i in range(n):
petal(t, r, angle)
t.lt(360.0/n)
def move(t, length):
#Move turtle(t) forwoard (length) units without leaving a trail
t.pu()
t.fd(length)
t.pd()
bob = turtle.Turtle()
#draw a sequence of three flowers
move(bob, -100)
flower(bob, 7, 60.0, 60.0)
move(bob, 100)
flower(bob, 10, 40.0, 80.0)
move(bob, 100)
flower(bob, 20, 140.0, 20.0)
bob.hideturtle()
turtle.mainloop()
各位愛學(xué)習(xí)的同學(xué)有沒有學(xué)到呢,
歡迎各位寶寶加入小編的交流qun
點(diǎn)擊鏈接加入群聊【Python技術(shù)交流】:https://jq.qq.com/?_wv=1027&k=5SvRhJ9
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
