我正在尝试编写一个代码,在其中龟用闲置的python绘制您键入的单词,并且按字母顺序(字母bc是我编写的顺序)绘制字母,但我不知道如何更改它。请帮助!我们将不胜感激。(我知道只有3个字母我没有时间编写更多代码。here is the code
答案 0 :(得分:0)
作为一个简单的解决方法,您应该将space, a, b
和c
定义为函数,然后按照从文本中获得的顺序进行调用。
print ("Hello and welcome to word drawing")
text = input ("Enter your text you want to print:")
selectedcolour = input ("What colour would you like it?")
thick = input ("How thick would you like it? (min:1 max:100)")
import turtle
forward=turtle.forward
back=turtle.backward
right=turtle.right
left=turtle.left
pup=turtle.penup
pdown=turtle.pendown
colour=turtle.color
thickness=turtle.width
colour(selectedcolour)
thickness(thick)
pup()
left(180)
forward(400)
left(180)
pdown()
def space():
pup()
forward(100)
pdown()
def a():
for i in range(450): #this is an A
forward(2)
left(1)
forward(140)
right(180)
forward(240)
for i in range(90):
forward(1)
left(1)
pup()
forward(100)
left(90)
forward(25)
right(90)
pdown()
def b():
left(90)
forward(300)
back(250)
for i in range(180):
forward(3)
right(2)
back(100)
pup()
right(90)
forward(300)
pdown()
def c():
pup()
forward(100)
left(90)
forward(50)
right(90)
pdown()
right(135)
for i in range(275):
forward(2)
right(1)
pup()
right(45)
forward(200)
left(90)
forward(100)
pdown()
draw = {" ":space, "a":a, "b":b, "c":c}
for letter in text:
if letter in draw.keys():
draw[letter]()
答案 1 :(得分:0)
#other letters
def d():
left(90)
forward(300)
back(250)
for i in range(180):
forward(3)
left(2)
back(100)
pup()
left(90)
forward(300)
pdown()
def e():
forward(100)
back(100)
left(90)
forward(100)
left(90)
back(100)
forward(100)
right(90)
forward(100)
right(90)
forward(100)
def f():
left(90)
forward(100)
right(90)
forward(100)
back(100)
forward(100)
back(100)
left(90)
forward(100)
right(90)
forward(100)
def g():
left(90)
forward(70)
left(90)
forward(70)
left(90)
forward(63)
left(90)
pdown()
right(135)
for i in range(275):
forward(2)
right(1)
pup()