dot () print ( "Inside of quarter-circle:" ) print ( inside ) print ( "Total amount of points:" ) print ( np ) print ( "Pi is approximately:" ) print (( inside / np ) * 4.0 ) turtle. sqrt ( x ** 2 + y ** 2 ) if d <= length : inside += 1 turtle. uniform ( 0, length ) #determine distance from center d = math. circle ( length, - 90 ) inside = 0 for i in range ( 0, np ): #get dot position x = random. pendown () #draw quarter of circle turtle. speed ( "fastest" ) length = 300 # radius of circle and length of the square in pixels #draw y axis turtle. isdigit (): print ( "Insert number of points:" ) np = input () np = int ( np ) turtle. Calculates circular constant Pi using the Ramanujan-type formula. Import random import math import turtle print ( "Insert number of points:" ) np = input () while not np. However, it is a method that is easy to imagine and visualize (at the cost of even slower performance). You will have to wait quite long to get the same amount of digits of π as, for example, the Nilakantha series.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |