Strings in Turtle Graphics
Using Strings In Turtle
We can use the turtle package to write text to the screen. Copy and past the following code into a new files called SpiralMyName.py
There are a few lines here that are new:
Because we are displaying the turtle screen, we need to use the turtle.textinput
t.penup()
lift the pen from the screen so that nothing is drawn. We then move it forward with t.forward()
before putting the pen back down with t.pendown()
t.write is the command used to write text to the turtle screen.
The font key-word argument takes the variables font = ( [font_name], [font_size], [font_weight])
so here we are using the Times New Roman font with an increasing font size in bold.
You can also use Arial and Courier as fonts
Play around with your program and make something that looks amazing!
Last updated