そのため、タートルを使用して特定の文字を描画するプログラムを作成しており、入力プロンプトに基づいてプログラムのサイズとペンの太さに影響を与えるパラメータースケールを設定しました。これが私が持っているものです...スケールが定義されていないというエラーが表示され続けます。
import turtle
def drawLetter( letter ):
if letter == " ":
space(scale)
elif letter == "i":
i_lc(scale)
elif letter == "I":
i_uc(scale)
elif letter == "s":
s_lc(scale)
elif letter == "S":
s_uc(scale)
elif letter == "C":
c_uc(scale)
elif letter == "c":
c_lc(scale)
def space(scale):
turtle.up()
turtle.forward( 30 * scale )
def questionMark():
""" Draw a question mark.
"""
turtle.forward( 10 )
turtle.down()
turtle.left( 90 )
turtle.forward( 2 )
turtle.up()
turtle.forward( 3 )
turtle.down()
turtle.forward( 5 )
turtle.right( 90 )
turtle.forward( 10 )
turtle.left( 90 )
turtle.forward( 10 )
turtle.left( 90 )
turtle.forward( 20 )
turtle.left( 90 )
turtle.forward( 5 )
turtle.up()
turtle.forward( 15 )
turtle.left( 90 )
turtle.forward ( 30 )
def i_uc(scale):
""" Draw an upper case I.
"""
turtle.down()
turtle.forward( 10 )
turtle.left( 90 )
turtle.forward( 20 )
turtle.left( 90 )
turtle.forward( 10 )
turtle.left( 180 )
turtle.forward( 20 )
turtle.left( 180 )
turtle.forward( 10 )
turtle.left( 90 )
turtle.forward( 20 )
turtle.left( 90 )
turtle.forward( 10 )
turtle.up()
turtle.forward( 10 )
def i_lc(scale):
""" Draw a lower case i.
"""
turtle.forward( 10 )
turtle.down()
turtle.left( 90 )
turtle.forward( 11 )
turtle.up()
turtle.forward( 2 )
turtle.down()
turtle.forward( 2 )
turtle.up()
turtle.right( 180 )
turtle.forward( 15 )
turtle.left( 90 )
turtle.forward( 20 )
def s_uc(scale):
""" Draw an upper case S.
"""
turtle.left( 90 )
turtle.forward( 20 )
turtle.right( 90 )
turtle.forward( 20 )
turtle.right( 180 )
turtle.down()
turtle.forward( 20 )
turtle.left( 90 )
turtle.forward( 10 )
turtle.left( 90 )
turtle.forward( 20 )
turtle.right( 90 )
turtle.forward( 10 )
turtle.right( 90 )
turtle.forward( 20 )
turtle.left( 180 )
turtle.up()
turtle.forward( 30 )
def s_lc(scale):
""" Draw a lower case s.
"""
turtle.down()
turtle.forward( 20 * scale )
turtle.left( 90 )
turtle.forward( 5 * scale )
turtle.left( 90 )
turtle.forward( 20 * scale )
turtle.right( 90 )
turtle.forward( 5 * scale )
turtle.right( 90 )
turtle.forward( 20 * scale )
turtle.up()
turtle.right( 90 )
turtle.forward( 10 * scale )
turtle.left( 90 )
turtle.forward( 10 * scale )
def c_uc(scale):
turtle.down()
turtle.forward( 20 * scale )
turtle.forward( -20 * scale )
turtle.left( 90 )
turtle.forward( 20 * scale )
turtle.right( 90 )
turtle.forward( 20 * scale )
turtle.forward( -20 * scale )
turtle.left( 90 )
turtle.forward( -20 * scale )
turtle.up()
turtle.right( 90 )
turtle.forward( 20 * scale )
def c_lc(scale):
turtle.down()
turtle.forward( 20 * scale )
turtle.forward( -20 * scale )
turtle.left( 90 )
turtle.forward( 10 * scale )
turtle.right( 90 )
turtle.forward( 20 * scale )
turtle.forward( -20 * scale )
turtle.left( 90 )
turtle.forward( -10 * scale )
turtle.up()
turtle.right( 90 )
turtle.forward( 20 * scale )
def main():
scale == input("Enter scale:")
turtle.pensize(scale)