Advertisement
Guest User

Untitled

a guest
Feb 14th, 2017
4,415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. # Computes pi
  2. # ToDo: draw a bigger circle for more precision
  3.  
  4. s = ('    __    \n'
  5.      '  -    -  \n'
  6.      ' -      - \n'
  7.      '|        -\n'
  8.      ' -      - \n'
  9.      '  -    -  \n'
  10.      '    --    \n')
  11.  
  12. c = 0.0
  13. r = 0.0
  14.  
  15. for _ in s:
  16.     if _ == '-':
  17.         c += 1.0
  18.     if _ == '\n':
  19.         r += 1.0
  20.  
  21. # Each Symbol accounts for 2 units in circumference
  22. c *= 2
  23.  
  24. # Radius, not diameter
  25. r /= 2
  26.  
  27. print(c/2/r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement