User Tools

Site Tools


slush:codetalkers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
slush:codetalkers [2017/05/19 14:21] oemb1905slush:codetalkers [2018/05/20 01:29] (current) – removed oemb1905
Line 1: Line 1:
-flip.py 
-  import random 
-  total = 0 
-  for i in range(2000000000000000000): 
-      flip = random.randint(0, 1) 
-      total = total + flip 
-      average = total / (i + 1)  
-      print(i, flip, total, average) 
-       
-pi.py 
-  import random 
-  def main(): 
-      N_sq = 0 
-      N_circ = 0 
-      n_iterations = 10000000000 
-      for i in range (n_iterations): 
-          x = random.random() * 2 - 1 
-          y = random.random() * 2 - 1 
-          N_sq = N_sq + 1 #Always in square 
-          if x*x + y*y < 1: 
-              N_circ = N_circ + 1 
-          pi_estimate = 4.0 * float(N_circ) / float(N_sq) 
-          if i % (n_iterations/10000000000) == 0: 
-              print('%d    %f' % (i, pi_estimate)) 
-  main() 
- 
-walk.py 
- 
-  import random 
-  import math 
- 
-  x = 0 
-  y = 0 
-  for i in range(20000): 
-      flipx = random.randint(-1, 1) 
-      flipy = random.randint(-1, 1) 
-      x = x + flipx 
-      y = y + flipy   
-      r = math.sqrt(x*x + y*y) 
-      print(i, x, y, r) 
- 
-General Instructions (Taken from Comments Section on old Code Talkers Classroom) 
- 
-{{:slush:1.png?600|}} 
- 
-{{:slush:2.png?600|}} 
- 
- 
- 
  
slush/codetalkers.1495203704.txt.gz · Last modified: 2018/11/25 01:33 (external edit)