Home > other >  Draw a star in Python
Draw a star in Python

Time:12-29

After a while, please code is what mean? Come on come on

CodePudding user response:

 import turtle as t 
T.f illcolor (" red ")
T.b egin_fill (#) to fill the
While True:
T.f orward (200)
T.r d.light (144) # 200, here to go straight to the right and then left turn 144 ° (is the pentagram degree, 180/5=36 ° 180-36=144)
If abs (t.p OS ()) & lt; # 1: first use t.p OS () to obtain returns the current coordinates (x, y) sea turtles (for & lt; The class 'turtle. Vec2D & gt; Vector class object), then the vector with the abs () function to calculate the mode (i.e., the distance to the origin of coordinates)
Break# fifth traversed when the tortoise will return to the origin, the model is equal to zero at this time, trigger the beak, the end of the cycle,
T.e nd_fill () # populated
Brush, t.d one (#) stop, but drawing form not to close,

I've given up the meaning of each row mark, in order to facilitate understanding, the following five points in a given star coordinates and the distance to the origin, (in the order traversal)
 
(200.00, 0.00)200.0

(38.20, 117.56)
123.606797749979

(100.00, 72.65)
123.60679774997895

(161.80, 117.56)
200.0

(0.00, 0.00)
5.123796534383003 e-14

CodePudding user response:

reference 1st floor GeofferyLibrom response:
 import turtle as t 
T.f illcolor (" red ")
T.b egin_fill (#) to fill the
While True:
T.f orward (200)
T.r d.light (144) # 200, here to go straight to the right and then left turn 144 ° (is the pentagram degree, 180/5=36 ° 180-36=144)
If abs (t.p OS ()) & lt; # 1: first use t.p OS () to obtain returns the current coordinates (x, y) sea turtles (for & lt; The class 'turtle. Vec2D & gt; Vector class object), then the vector with the abs () function to calculate the mode (i.e., the distance to the origin of coordinates)
Break# fifth traversed when the tortoise will return to the origin, the model is equal to zero at this time, trigger the beak, the end of the cycle,
T.e nd_fill () # populated
Brush, t.d one (#) stop, but drawing form not to close,

I've given up the meaning of each row mark, in order to facilitate understanding, the following five points in a given star coordinates and the distance to the origin, (in the order traversal)
 
(200.00, 0.00)200.0

(38.20, 117.56)
123.606797749979

(100.00, 72.65)
123.60679774997895

(161.80, 117.56)
200.0

(0.00, 0.00)
5.123796534383003 e-14

Thank you, thank you, thank you very much??

CodePudding user response:

refer to the second floor m0_53366173 response:
Quote: refer to 1st floor GeofferyLibrom response:
 import turtle as t 
T.f illcolor (" red ")
T.b egin_fill (#) to fill the
While True:
T.f orward (200)
T.r d.light (144) # 200, here to go straight to the right and then left turn 144 ° (is the pentagram degree, 180/5=36 ° 180-36=144)
If abs (t.p OS ()) & lt; # 1: first use t.p OS () to obtain returns the current coordinates (x, y) sea turtles (for & lt; The class 'turtle. Vec2D & gt; Vector class object), then the vector with the abs () function to calculate the mode (i.e., the distance to the origin of coordinates)
Break# fifth traversed when the tortoise will return to the origin, the model is equal to zero at this time, trigger the beak, the end of the cycle,
T.e nd_fill () # populated
Brush, t.d one (#) stop, but drawing form not to close,

I've given up the meaning of each row mark, in order to facilitate understanding, the following five points in a given star coordinates and the distance to the origin, (in the order traversal)
 
(200.00, 0.00)200.0

(38.20, 117.56)
123.606797749979

(100.00, 72.65)
123.60679774997895

(161.80, 117.56)
200.0

(0.00, 0.00)
5.123796534383003 e-14

Thank you, thank you, thank you very much?

Ok, that "

CodePudding user response:

reference GeofferyLibrom reply: 3/f
Quote: refer to the second floor m0_53366173 response:
Quote: refer to 1st floor GeofferyLibrom response:
 import turtle as t 
T.f illcolor (" red ")
T.b egin_fill (#) to fill the
While True:
T.f orward (200)
T.r d.light (144) # 200, here to go straight to the right and then left turn 144 ° (is the pentagram degree, 180/5=36 ° 180-36=144)
If abs (t.p OS ()) & lt; # 1: first use t.p OS () to obtain returns the current coordinates (x, y) sea turtles (for & lt; The class 'turtle. Vec2D & gt; Vector class object), then the vector with the abs () function to calculate the mode (i.e., the distance to the origin of coordinates)
Break# fifth traversed when the tortoise will return to the origin, the model is equal to zero at this time, trigger the beak, the end of the cycle,
T.e nd_fill () # populated
Brush, t.d one (#) stop, but drawing form not to close,

I've given up the meaning of each row mark, in order to facilitate understanding, the following five points in a given star coordinates and the distance to the origin, (in the order traversal)
 
(200.00, 0.00)200.0

(38.20, 117.56)
123.606797749979

(100.00, 72.65)
123.60679774997895

(161.80, 117.56)
200.0

(0.00, 0.00)
5.123796534383003 e-14

Thank you, thank you, thank you very much?

Ok, that "

Zha "ah, I never used before, just know today can ask questions,

CodePudding user response:


Post right!
  • Related