Description of the use of the methodology
See Python's turtle module for more information on turtle:https:///article/
(method
Write text at the current turtle position. As:
("Hello.", align="center",font=("Song Style",10,"normal"))
included among these
Hi. The text written into the Turtle painting screen is in string format, with quotes.
move (optional): by default, move is false. if move is true, the pen will move to the lower right corner.
align (optional): can take the value of left is left, center is center, right is right one, is a string format.
font (optional): font triad (fontname, fontsize, fonttype), fontname is the font name, fontsize is the font size, fonttype is the font type such as: normal, bold, italic.
(for) instance
import turtle info = "The text you typed." () (-300) ('red') for i in info: (i, font=('Song Style',40,'normal')) (60) ()
The running effect is as follows:
Example of drawing a small flower
import turtle as t () (-200) ("A little flower\n", align="right", font=("Italics.", 16, "bold")) def draw_leaf(): for i in range(2): for j in range(15): (5) (6) (90) (0,-150) (90) () (50) ("green") t.begin_fill() draw_leaf() t.end_fill() (50) (270) ("green") t.begin_fill() draw_leaf() t.end_fill() (90) (130) ("red") t.begin_fill() for i in range(6): draw_leaf() (60) t.end_fill() ()
The running effect is as follows:
How do I use a method to display text as a circle?
The trajectory of the brush can be approximated as a square polygon.
According to the formula for the sum of the interior angles of a polygon: degree = (number of sides - 2)*180.
Then, the number of degrees for each rotation is: 180 - degrees / angles = 180 - (sides - 2) * 180 / sides.
It is easy to know that the number of sides = the number of corners = the number of words.
So the number of degrees per rotation is:180-(number of texts-2)*180/number of texts=360/number of texts.
for example
#Display text as a circle import turtle text="The text you want to display." () x=len(text) for i in text: (i,font='consolas') (360/x) () (30) ()
The running effect is as follows:
summarize
This article on the use of methods in Python is introduced to this article, more related Python methods to use content please search for my previous articles or continue to browse the following related articles I hope you will support me in the future!