TheAceHome

Untitled

Oct 18th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import random
  2. import matplotlib
  3. import matplotlib.pyplot as plt
  4. %matplotlib inline
  5. def A(N):
  6.     n = 0
  7.     for i in range(N):
  8.         x = random.randint(1, 100)
  9.         y = random.randint(1, 100)
  10.         z = random.randint(1, 100)
  11.         if x <= 5 or y <= 70 or z <= 31:
  12.             n += 1
  13.     return n/N
  14. N = 10000
  15. print("Answer:")
  16. print(A(N))
  17. x = [i for i in range(1, 10000, 100)]
  18. y1 = [A(i) for i in x]
  19.  
  20. plt.plot(x[2:], y1[2:])
  21. plt.title('PLOT')
  22. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment