{"id":349,"date":"2019-01-26T19:12:17","date_gmt":"2019-01-27T03:12:17","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=349"},"modified":"2019-01-26T19:12:29","modified_gmt":"2019-01-27T03:12:29","slug":"circle-of-diamonds-using-turtle","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/circle-of-diamonds-using-turtle\/","title":{"rendered":"Circle of diamonds using turtle"},"content":{"rendered":"<pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport os\nimport turtle\nos.chdir(r'D:\\projects\\wordpress\\ex56')\nos.getcwd()\n\ndef draw_diamond(some_turtle):\n    some_turtle.left(30)\n    some_turtle.forward(200)\n    some_turtle.right(60)\n    some_turtle.forward(200)\n    some_turtle.right(120)\n    some_turtle.forward(200)\n    some_turtle.right(60)\n    some_turtle.forward(200)\n    some_turtle.right(150)\n\ndef draw_art():\n    window = turtle.Screen()\n    window.bgcolor(&quot;white&quot;)\n    brad = turtle.Turtle()\n    brad.color(&quot;blue&quot;)\n    brad.speed(0)\n    # Draw a circle with 36 diamonds. We rotate each diamond by 10 degrees at a time.\n    for i in range (0, 36):\n        draw_diamond(brad)\n        brad.right(10)\n    window.exitonclick()      # click on the window to exit\n\ndraw_art()\nturtle.mainloop()\n<\/pre>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"  wp-image-350 aligncenter\" src=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example56.png?resize=610%2C604&#038;ssl=1\" alt=\"example56\" width=\"610\" height=\"604\" srcset=\"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example56.png?w=721&amp;ssl=1 721w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example56.png?resize=150%2C150&amp;ssl=1 150w, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example56.png?resize=300%2C298&amp;ssl=1 300w\" sizes=\"(max-width: 610px) 100vw, 610px\" \/><br \/>\n&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>import os import turtle os.chdir(r&#8217;D:\\projects\\wordpress\\ex56&#8242;) os.getcwd() def draw_diamond(some_turtle): some_turtle.left(30) some_turtle.forward(200) some_turtle.right(60) some_turtle.forward(200) some_turtle.right(120) some_turtle.forward(200) some_turtle.right(60) some_turtle.forward(200) some_turtle.right(150) def draw_art(): window = turtle.Screen() window.bgcolor(&quot;white&quot;) brad = turtle.Turtle() brad.color(&quot;blue&quot;) brad.speed(0) # Draw a circle with 36 diamonds. We rotate each diamond by 10 degrees at a time. for i in range (0, 36): draw_diamond(brad) brad.right(10) window.exitonclick() # [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2,13],"tags":[],"class_list":["post-349","post","type-post","status-publish","format-standard","hentry","category-python","category-turtle"],"modified_by":null,"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-5D","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":269,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/circle-of-squares-using-turtle\/","url_meta":{"origin":349,"position":0},"title":"Circle of squares using turtle","author":"gantovnik","date":"2019-01-20","format":false,"excerpt":"[code language=\"python\"] import os import turtle os.chdir(r'D:\\projects\\wordpress\\ex51') os.getcwd() def draw_square(some_turtle): for i in range (1,5): some_turtle.forward(200) some_turtle.right(90) def draw_art(): #Turtle Brad n=5 brad = turtle.Turtle() brad.speed(10) for i in range(1,int(360\/n)+1): draw_square(brad) brad.right(n) draw_art() turtle.mainloop() [\/code] \u00a0 \u00a0","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"figure51","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/figure51.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/figure51.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/figure51.png?resize=525%2C300 1.5x"},"classes":[]},{"id":993,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/10\/177-random-snowflakes-using-python-turtle\/","url_meta":{"origin":349,"position":1},"title":"#177 Random snowflakes using python turtle","author":"gantovnik","date":"2021-10-06","format":false,"excerpt":"#177 Random snowflakes using python turtle [code language=\"python\"] import turtle from random import randint def generate_random_colour(): # Generates an R,G,B values randomly in range 0 to 255 r = randint(0, 255) g = randint(0, 255) b = randint(0, 255) return r, g, b def setup_screen(title, background = 'white'): print('Set up\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/10\/ex177.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/10\/ex177.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/10\/ex177.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":996,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/10\/178-fractal-tree-using-python-turtle\/","url_meta":{"origin":349,"position":2},"title":"#178 Fractal tree using python turtle","author":"gantovnik","date":"2021-10-06","format":false,"excerpt":"#178 Fractal tree using python turtle [code language=\"python\"] import turtle # Set up 'constants' # image size IMAGE_SIZE_X = 500 IMAGE_SIZE_Y = 500 # Determines depth of tree - try 2 and 1.25 as alternatives FACTOR = 1.45 def draw_tree(length, width=9): color = 'brown' if length < 1: return elif\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/10\/ex178.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":990,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/10\/176-the-koch-snowflake-using-python-turtle\/","url_meta":{"origin":349,"position":3},"title":"#176 The Koch snowflake using python turtle","author":"gantovnik","date":"2021-10-05","format":false,"excerpt":"#176 The Koch snowflake using python turtle import turtle # Set up Constants ANGLES = [60, -120, 60, 0] SIZE_OF_SNOWFLAKE = 300 def get_input_depth(): depth = 9 return depth def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=800): print('Set up Screen') turtle.title(title) turtle.setup(screen_size_x, screen_size_y) turtle.hideturtle() turtle.penup() turtle.backward(240) # Batch drawing to the screen\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/10\/ex176.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":987,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/10\/175-turtle-graphics-in-python\/","url_meta":{"origin":349,"position":4},"title":"#175 Turtle graphics in python","author":"gantovnik","date":"2021-10-05","format":false,"excerpt":"#175 Turtle graphics in python [code language=\"python\"] import turtle from random import randint def get_input_angle(): angle = 199 return angle def generate_random_colour(): # Generates an R,G,B values randomly in range 0 to 255 r = randint(0, 255) g = randint(0, 255) b = randint(0, 255) return r, g, b print('Set\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/10\/ex175.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/10\/ex175.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/10\/ex175.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1915,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/08\/373-scatterplot-with-multiple-semantics-using-seaborn-library\/","url_meta":{"origin":349,"position":5},"title":"#373 Scatterplot with multiple semantics using seaborn library","author":"gantovnik","date":"2023-08-09","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt import os from scipy.special import fresnel #conda install -c anaconda seaborn import seaborn as sns sns.set_theme(style=\"whitegrid\") def main(): # Load the example diamonds dataset diamonds = sns.load_dataset(\"diamonds\") # Draw a scatter plot while assigning point colors and sizes to different\u2026","rel":"","context":"In &quot;plot&quot;","block_context":{"text":"plot","link":"https:\/\/gantovnik.com\/bio-tips\/category\/plot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/08\/ex373.png?resize=1050%2C600&ssl=1 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=349"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/349\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}