Skip to main content

Posts

Showing posts from May, 2021

Drawing a star with stamp of turtle in python!

  Here is the code for the same: import   turtle star = turtle . Turtle () star. color ( "pink" ) star. shape ( "turtle" ) wn = turtle . Screen () wn. bgcolor ( "black" ) for  i  in   range ( 100 ):     star. forward ( 200 + 20 * i)     star. stamp ()     star. right ( 144 ) turtle . speed ( 9 ) turtle .done() Output of the above code: 

What is turtle.stamp() in python?

turtle.stamp() turtle.stamp() is used to stamp a copy of the turtle shape, it prints the shape at that point and moves forward with the instructions. Here shape of the turtle does not matter. It does the same for every turtle shape.  Example:  Here is the example of stamp() used: import   turtle def   tri ():      for   i   in   range ( 10 ):          turtle . degrees ( 60 )          turtle . forward ( 200 + 10 * i )          turtle . stamp ()          turtle . right ( 200 ) turtle . speed ( 7 ) turtle . color ( "orange" )         tri () turtle . done () For more such posts, stay tuned!

Drawing Heart using python turtle!

  import   turtle def   curve ():      for   i   in   range ( 200 ):          turtle . right ( 1 )          turtle . forward ( 1 ) turtle . color ( "red" ) turtle . begin_fill () turtle . left ( 140 ) turtle . forward ( 111.65 ) curve () turtle . left ( 120 ) curve () turtle . forward ( 111.65 ) turtle . end_fill () turtle . hideturtle () turtle . done () Code reference: @pythongrowin