1 import turtle 2 3 #坐標原點 4 x = int(input('原點坐標x,整數:') or '-300') 5 y = int(input('原點坐標y,整數:') or '-300') 6 7 #橫線 豎線 的數量 8 l1 = int(input('請輸入棋盤長,正整數:') or '18') 9 k1 = l1 10 11 #線條間隔 12 jg = int(input('請輸入棋盤間隔,正整數:')or '30') 13 14 t = turtle.Pen() 15 t.speed(10) 16 t.color('green') 17 18 19 #畫橫線 20 t.penup() 21 t.goto(x,y) 22 for n in range(0,l1): 23 t.penup() 24 t.goto(x,y+n*jg) 25 t.pendown() 26 t.goto(x+(l1-1)*jg,y+n*jg) 27 28 #畫豎線 29 t.penup() 30 t.goto(x,y) 31 for m in range(0,k1): 32 t.penup() 33 t.goto(x+m*jg,y) 34 t.pendown() 35 t.goto(x+m*jg,y+(k1-1)*jg) 36 37 t.hideturtle() 38 turtle.done()
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/51282.html
標籤:Python
下一篇:在Linux使用虛擬環境
